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

Fixes (restores) route ordering #859

Merged
merged 6 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
* [#846](https://github.com/ruby-grape/grape-swagger/pull/846): Refactor oapi fetch task [@Vachman](https://github.com/Vachman)
* [#850](https://github.com/ruby-grape/grape-swagger/pull/850): Fix value of enum to be Array [@takahashim](https://github.com/takahashim)


### 1.4.3 (January 5, 2022)

#### Fixes
Expand Down
2 changes: 1 addition & 1 deletion lib/grape-swagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def combine_routes(app, doc_klass)
@target_class.combined_routes[resource] ||= []
next if doc_klass.hide_documentation_path && route.path.match(/#{doc_klass.mount_path}($|\/|\(\.)/)

@target_class.combined_routes[resource].unshift route
@target_class.combined_routes[resource] << route
end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/grape-swagger/rake/oapi_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def validate
resource - if given only for that it would be generated (optional)'
task validate: :environment do
# :nocov:
ENV['store'] = 'true'
ENV.store('store', 'true')
::Rake::Task['oapi:fetch'].invoke
exit if error?

Expand Down Expand Up @@ -108,7 +108,7 @@ def format_path(path)
end

def save_to_file?
ENV['store'].present? && !error?
ENV.fetch('store', nil).present? && !error?
end

def error?
Expand All @@ -118,10 +118,10 @@ def error?
def file(url)
api_version = url.split('/').last

name = if ENV['store'] == 'true' || ENV['store'].blank?
name = if ENV.fetch('store', nil) == 'true' || ENV.fetch('store', nil).blank?
"swagger_doc_#{api_version}.json"
else
ENV['store'].sub('.json', "_#{api_version}.json")
ENV.fetch('store').sub('.json', "_#{api_version}.json")
end

File.join(Dir.getwd, name)
Expand Down
13 changes: 1 addition & 12 deletions spec/swagger_v2/mount_override_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,13 @@ def app
end

Class.new(Grape::API) do
mount new_api
mount old_api
mount new_api

add_swagger_documentation format: :json
end
end

context 'actual api request' do
LeFnord marked this conversation as resolved.
Show resolved Hide resolved
subject do
get '/'
last_response.body
end

it 'returns data from new endpoint' do
is_expected.to eq 'new'
end
end

context 'api documentation' do
subject do
get '/swagger_doc'
Expand Down