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

Dependencies update #948

Merged
merged 3 commits into from
Feb 19, 2025
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: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/grape-swagger/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def content_types_for(target_class)
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
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/move_params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
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)
Expand Down Expand Up @@ -128,7 +128,7 @@

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)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/operation_id_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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' }
Expand Down
11 changes: 11 additions & 0 deletions spec/support/route_helper.rb
Original file line number Diff line number Diff line change
@@ -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