Dependencies update (#948)
* Add spec route helper to complain with Grape >= 2.3.0 * Explicitly add ostruct gem in case of Ruby 3.5 * Update CHANGELOG
This commit is contained in:
parent
599712eb34
commit
3e842a138b
|
@ -7,6 +7,7 @@
|
|||
#### Fixes
|
||||
|
||||
* your contribution
|
||||
* [#948](https://github.com/ruby-grape/grape-swagger/pull/948): Grape 2.3.0 and Ruby 3.5 compatibility - [@numbata](https://github.com/numbata)
|
||||
|
||||
|
||||
### 2.1.2 (Jan 7, 2025)
|
||||
|
|
3
Gemfile
3
Gemfile
|
@ -37,6 +37,9 @@ group :development, :test do
|
|||
unless ENV['MODEL_PARSER'] == 'grape-swagger-entity'
|
||||
gem 'grape-swagger-entity', git: 'https://github.com/ruby-grape/grape-swagger-entity'
|
||||
end
|
||||
|
||||
# Conditionally load 'ostruct' only if Ruby >= 3.5.0
|
||||
gem 'ostruct' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.5.0')
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
|
|
@ -12,7 +12,7 @@ module Grape
|
|||
if content_types.empty?
|
||||
formats = [target_class.format, target_class.default_format].compact.uniq
|
||||
formats = GrapeSwagger::FORMATTER_DEFAULTS.keys if formats.empty?
|
||||
content_types = GrapeSwagger::CONTENT_TYPE_DEFAULTS.select do |content_type, _mime_type|
|
||||
content_types = GrapeSwagger::CONTENT_TYPE_DEFAULTS.select do |content_type, _mime_type| # rubocop:disable Style/HashSlice
|
||||
formats.include? content_type
|
||||
end.values
|
||||
end
|
||||
|
|
|
@ -97,7 +97,7 @@ describe GrapeSwagger::DocMethods::MoveParams do
|
|||
let(:route_options) { { requirements: {} } }
|
||||
describe 'POST' do
|
||||
let(:params) { paths[path][:post][:parameters] }
|
||||
let(:route) { Grape::Router::Route.new('POST', path.dup, **route_options) }
|
||||
let(:route) { RouteHelper.build(method: 'POST', pattern: path.dup, options: route_options) }
|
||||
|
||||
specify do
|
||||
subject.to_definition(path, params, route, definitions)
|
||||
|
@ -128,7 +128,7 @@ describe GrapeSwagger::DocMethods::MoveParams do
|
|||
|
||||
describe 'PUT' do
|
||||
let(:params) { paths['/in_body/{key}'][:put][:parameters] }
|
||||
let(:route) { Grape::Router::Route.new('PUT', path.dup, **route_options) }
|
||||
let(:route) { RouteHelper.build(method: 'PUT', pattern: path.dup, options: route_options) }
|
||||
|
||||
specify do
|
||||
subject.to_definition(path, params, route, definitions)
|
||||
|
|
|
@ -9,7 +9,7 @@ describe GrapeSwagger::DocMethods::OperationId do
|
|||
specify { expect(subject).to respond_to :build }
|
||||
|
||||
describe 'build' do
|
||||
let(:route) { Grape::Router::Route.new(method, '/path', requirements: {}) }
|
||||
let(:route) { RouteHelper.build(method: method, pattern: '/path', options: { requirements: {} }) }
|
||||
|
||||
describe 'GET' do
|
||||
let(:method) { 'GET' }
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module RouteHelper
|
||||
def self.build(method:, pattern:, options:, origin: nil)
|
||||
if GrapeVersion.satisfy?('>= 2.3.0')
|
||||
Grape::Router::Route.new(method, origin || pattern, pattern, options)
|
||||
else
|
||||
Grape::Router::Route.new(method, pattern, **options)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue