Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade routes:oas:docs cmd #117

Merged
merged 15 commits into from
May 2, 2020
Merged

Upgrade routes:oas:docs cmd #117

merged 15 commits into from
May 2, 2020

Conversation

yukihirop
Copy link
Owner

@yukihirop yukihirop commented May 2, 2020

Summary

Resolve #113

Minor update 🎉

.docs is needed to continue using r2-oas
If you are using previous version, you need to run the following command to generate .docs.

CACHE_DOCS=true bundle exec rake routes:oas:docs

A .docs file is like a git object in git. This file made the three way merge possible.
Thanks to the .docs file, when an endpoint is added to the API (changed config/routes.rb),
you can hit the following command to generate a document template. The same applies to deletion.

# Automatically generate additional API documentation
bundle exec rake routes:oas:docs

Works

Running .docs without a .docs file causes an error

rake aborted!
R2OAS::NoFileExistsError:
                Can't find the file ./oas_docs/.docs
                Please execute the following command to create ./oas_docs/.docs

                CACHE_DOCS=true bundle exec rake routes:oas:docs

When you execute the command according to the instruction, the .docs file is generated and can be used.

$ CACHE_DOCS=true bundle exec rake routes:oas:docs
.
.
.
.
I, [2020-05-02T14:13:57.038427 #22826]  INFO -- : [Generate OAS docs] Create cache at ./oas_docs/.docs
I, [2020-05-02T14:13:57.038494 #22826]  INFO -- : [Generate OAS schema files] end
I, [2020-05-02T14:13:57.038507 #22826]  INFO -- : [R2-OAS] end

Let's change config / routes.rb as follows.

Rails.application.routes.draw do
  namespace :api do
    namespace :v2 do
+     resources :posts, only: [:index, :create]
-      resources :posts
    end
  end
  namespace :api do
    namespace :v1 do
+      resources :tasks, only: [:index, :create]
-      resources :tasks
    end
  end
  resources :users
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

If you execute the command in this state, the unnecessary API documentation will be deleted automatically.

image

image

The docs file has also been updated. Be sure to commit.

rspec

Finished in 11.78 seconds (files took 1.89 seconds to load)
217 examples, 0 failures

[Coveralls] Outside the CI environment, not sending data.

rubocop

$ be rubocop
Inspecting 164 files
....................................................................................................................................................................

164 files inspected, no offenses detected

@yukihirop yukihirop changed the title Upgrade docs cmd Upgrade routes:oas:docs cmd May 2, 2020
@yukihirop
Copy link
Owner Author

passed the test, so it is OK

@yukihirop yukihirop merged commit 37ccddf into master May 2, 2020
@yukihirop yukihirop deleted the upgrade_docs_cmd branch May 2, 2020 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade routes:oas:docs command
1 participant