From 08b8c2fe0518043e4a479453327068ab0285d6b9 Mon Sep 17 00:00:00 2001 From: peter scholz Date: Sat, 5 Sep 2020 00:52:12 +0200 Subject: [PATCH] Prepare release 1.3.0 (#808) - updates and satisfy rubocop 0.90 - fixes ruby warnings - adds truffelruby-head to travis --- .rubocop.yml | 7 +++++-- .travis.yml | 4 ++++ CHANGELOG.md | 9 ++++++++- Gemfile | 2 +- lib/grape-swagger/doc_methods/format_data.rb | 4 ++-- lib/grape-swagger/endpoint.rb | 4 ++-- lib/grape-swagger/rake/oapi_tasks.rb | 2 ++ lib/grape-swagger/version.rb | 2 +- spec/lib/move_params_spec.rb | 4 ++-- 9 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4397bb29..0300e532 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,7 @@ AllCops: Exclude: - vendor/**/* - example/**/* + NewCops: enable TargetRubyVersion: 2.7 # Layout stuff @@ -80,8 +81,12 @@ Style/CaseLikeIf: Style/ExponentialNotation: Enabled: true +Style/ExplicitBlockArgument: + Enabled: false + Style/HashAsLastArrayItem: Enabled: true + Style/HashEachMethods: Enabled: true @@ -114,5 +119,3 @@ Style/RedundantRegexpEscape: Style/SlicingWithRange: Enabled: false - - diff --git a/.travis.yml b/.travis.yml index 338ca585..4bb6ce4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,8 +29,12 @@ jobs: env: - rvm: jruby-head env: + - rvm: truffleruby-head + env: + script: bundle exec rake spec allow_failures: - rvm: 2.4.10 - rvm: ruby-head - rvm: jruby-head + - rvm: truffleruby-head diff --git a/CHANGELOG.md b/CHANGELOG.md index 75f81cfb..db1961bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,14 @@ #### Fixes * Your contribution here. -* [#804](https://github.com/ruby-grape/grape-swagger/pull/804): Don't overwrite model description with the route description. - [@Bhacaz](https://github.com/Bhacaz) + + +### 1.3.0 (September 3, 2020) + +#### Features + +* [#804](https://github.com/ruby-grape/grape-swagger/pull/804): Don't overwrite model description with the route description - [@Bhacaz](https://github.com/Bhacaz). + ### 1.2.1 (July 15, 2020) diff --git a/Gemfile b/Gemfile index 4ea1b11e..70fc4677 100644 --- a/Gemfile +++ b/Gemfile @@ -27,7 +27,7 @@ group :development, :test do gem 'rake' gem 'rdoc' gem 'rspec', '~> 3.9' - gem 'rubocop', '~> 0.88', require: false + gem 'rubocop', '~> 0.90', require: false end group :test do diff --git a/lib/grape-swagger/doc_methods/format_data.rb b/lib/grape-swagger/doc_methods/format_data.rb index 3ad2980f..b5c7d7c0 100644 --- a/lib/grape-swagger/doc_methods/format_data.rb +++ b/lib/grape-swagger/doc_methods/format_data.rb @@ -7,7 +7,7 @@ class << self def to_format(parameters) parameters.reject { |parameter| parameter[:in] == 'body' }.each do |b| related_parameters = parameters.select do |p| - p[:name] != b[:name] && p[:name].to_s.include?(b[:name].to_s.gsub(/\[\]\z/, '') + '[') + p[:name] != b[:name] && p[:name].to_s.include?("#{b[:name].to_s.gsub(/\[\]\z/, '')}[") end parameters.reject! { |p| p[:name] == b[:name] } if move_down(b, related_parameters) end @@ -30,7 +30,7 @@ def move_down(parameter, related_parameters) def add_braces(parameter, related_parameters) param_name = parameter[:name].gsub(/\A(.*)\[\]\z/, '\1') - related_parameters.each { |p| p[:name] = p[:name].gsub(param_name, param_name + '[]') } + related_parameters.each { |p| p[:name] = p[:name].gsub(param_name, "#{param_name}[]") } end def add_array(parameter, related_parameters) diff --git a/lib/grape-swagger/endpoint.rb b/lib/grape-swagger/endpoint.rb index 48e0699a..1246c4e6 100644 --- a/lib/grape-swagger/endpoint.rb +++ b/lib/grape-swagger/endpoint.rb @@ -11,7 +11,7 @@ def content_types_for(target_class) if content_types.empty? formats = [target_class.format, target_class.default_format].compact.uniq - formats = Grape::Formatter.formatters({}).keys if formats.empty? + formats = Grape::Formatter.formatters(**{}).keys if formats.empty? content_types = Grape::ContentTypes::CONTENT_TYPES.select do |content_type, _mime_type| formats.include? content_type end.values @@ -365,7 +365,7 @@ def hidden?(route, options) end def hidden_parameter?(value) - return false if value.dig(:required) + return false if value[:required] if value.dig(:documentation, :hidden).is_a?(Proc) value.dig(:documentation, :hidden).call diff --git a/lib/grape-swagger/rake/oapi_tasks.rb b/lib/grape-swagger/rake/oapi_tasks.rb index 22bf4688..0565fbf1 100644 --- a/lib/grape-swagger/rake/oapi_tasks.rb +++ b/lib/grape-swagger/rake/oapi_tasks.rb @@ -74,6 +74,7 @@ def validate # helper methods # + # rubocop:disable Style/StringConcatenation def make_request get url_for @@ -83,6 +84,7 @@ def make_request ) ) + "\n" end + # rubocop:enable Style/StringConcatenation def url_for oapi_route = api_class.routes[-2] diff --git a/lib/grape-swagger/version.rb b/lib/grape-swagger/version.rb index 57903c8c..5cb1201b 100644 --- a/lib/grape-swagger/version.rb +++ b/lib/grape-swagger/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module GrapeSwagger - VERSION = '1.2.1' + VERSION = '1.3.0' end diff --git a/spec/lib/move_params_spec.rb b/spec/lib/move_params_spec.rb index 91d810f3..e4abef96 100644 --- a/spec/lib/move_params_spec.rb +++ b/spec/lib/move_params_spec.rb @@ -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) { Grape::Router::Route.new('POST', path.dup, **route_options) } specify do subject.to_definition(path, params, route, definitions) @@ -113,7 +113,7 @@ describe 'POST' do let(:params) { paths['/in_body/{key}'][:put][:parameters] } - let(:route) { Grape::Router::Route.new('PUT', path.dup, route_options) } + let(:route) { Grape::Router::Route.new('PUT', path.dup, **route_options) } specify do subject.to_definition(path, params, route, definitions)