diff --git a/CHANGELOG.md b/CHANGELOG.md index 261ba8f2..90cef0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/grape-swagger.rb b/lib/grape-swagger.rb index d2a7a78b..f2691846 100644 --- a/lib/grape-swagger.rb +++ b/lib/grape-swagger.rb @@ -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 diff --git a/lib/grape-swagger/rake/oapi_tasks.rb b/lib/grape-swagger/rake/oapi_tasks.rb index caaf63d4..20a35c76 100644 --- a/lib/grape-swagger/rake/oapi_tasks.rb +++ b/lib/grape-swagger/rake/oapi_tasks.rb @@ -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? @@ -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? @@ -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) diff --git a/spec/swagger_v2/mount_override_api_spec.rb b/spec/swagger_v2/mount_override_api_spec.rb index 1f2eb256..4d086de1 100644 --- a/spec/swagger_v2/mount_override_api_spec.rb +++ b/spec/swagger_v2/mount_override_api_spec.rb @@ -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 - 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'