diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ad57d96..8cda30b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: rubocop: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: '3.2' @@ -23,17 +23,17 @@ jobs: - name: Run rubocop run: bundle exec rubocop --parallel --format progress - grape-16: + grape-17: runs-on: ubuntu-latest needs: ['rubocop'] env: - GRAPE_VERSION: '1.6.2' + GRAPE_VERSION: '1.7.1' strategy: matrix: - ruby-version: ['3.0', '3.1', '3.2', 'head'] + ruby-version: ['3.1', '3.2', 'head'] steps: - name: Check out branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -55,17 +55,17 @@ jobs: bundle update bundle exec rspec - grape-17: + grape-18: runs-on: ubuntu-latest needs: ['rubocop'] env: - GRAPE_VERSION: '1.7.1' + GRAPE_VERSION: '1.8.0' strategy: matrix: - ruby-version: ['3.0', '3.1', '3.2', 'head'] + ruby-version: ['3.1', '3.2', 'head'] steps: - name: Check out branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -94,10 +94,10 @@ jobs: GRAPE_VERSION: 'HEAD' strategy: matrix: - ruby-version: ['3.0', '3.1', '3.2', 'head'] + ruby-version: ['3.1', '3.2', 'head'] steps: - name: Check out branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.rubocop.yml b/.rubocop.yml index 1893914e..7b2bf145 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,7 @@ AllCops: Exclude: - vendor/**/* - example/**/* + UseCache: true NewCops: enable TargetRubyVersion: 3.2 SuggestExtensions: false @@ -24,30 +25,12 @@ Layout/LineLength: Exclude: - spec/**/* -Layout/SpaceAroundMethodCallOperator: - Enabled: true - # Lint stuff # Lint/ConstantDefinitionInBlock: Exclude: - spec/**/* -Lint/DeprecatedOpenSSLConstant: - Enabled: true - -Lint/DuplicateElsifCondition: - Enabled: true - -Lint/MixedRegexpCaptureTypes: - Enabled: true - -Lint/RaiseException: - Enabled: true - -Lint/StructNewOverride: - Enabled: true - # Metrics stuff # Metrics/BlockLength: @@ -71,66 +54,24 @@ Naming: # Style stuff # -Style/AccessorGrouping: - Enabled: true - Style/AsciiComments: Enabled: false -Style/ArrayCoercion: - Enabled: true - -Style/BisectedAttrAccessor: - Enabled: true - -Style/CaseLikeIf: - Enabled: true - -Style/ExponentialNotation: - Enabled: true - Style/ExplicitBlockArgument: Enabled: false -Style/HashAsLastArrayItem: - Enabled: true - -Style/HashEachMethods: - Enabled: true - -Style/HashLikeCase: - Enabled: true - Style/HashSyntax: Enabled: false -Style/HashTransformKeys: - Enabled: true - -Style/HashTransformValues: - Enabled: true - Style/OpenStructUse: Exclude: - spec/**/* -Style/RegexpLiteral: +Style/RedundantArrayConstructor: Enabled: false -Style/RedundantAssignment: - Enabled: true - -Style/RedundantFetchBlock: - Enabled: true - -Style/RedundantFileExtensionInRequire: - Enabled: true - -Style/RedundantRegexpCharacterClass: - Enabled: true - -Style/RedundantRegexpEscape: - Enabled: true +Style/RegexpLiteral: + Enabled: false Style/SlicingWithRange: Enabled: false diff --git a/Gemfile b/Gemfile index 44cbc738..9ea8fb76 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,10 @@ group :development, :test do gem 'rdoc' gem 'rspec', '~> 3.9' gem 'rubocop', '~> 1.50', require: false - gem 'webrick' + + unless ENV['MODEL_PARSER'] == 'grape-swagger-entity' + gem 'grape-swagger-entity', git: 'https://github.com/ruby-grape/grape-swagger-entity' + end end group :test do @@ -35,9 +38,3 @@ group :test do gem 'ruby-grape-danger', '~> 0.2.0', require: false gem 'simplecov', require: false end - -group :test, :development do - unless ENV['MODEL_PARSER'] == 'grape-swagger-entity' - gem 'grape-swagger-entity', git: 'https://github.com/ruby-grape/grape-swagger-entity' - end -end diff --git a/lib/grape-swagger/doc_methods/extensions.rb b/lib/grape-swagger/doc_methods/extensions.rb index 7dc3f261..0c5334f7 100644 --- a/lib/grape-swagger/doc_methods/extensions.rb +++ b/lib/grape-swagger/doc_methods/extensions.rb @@ -56,7 +56,8 @@ def find_definition(status, path) return if response.nil? return response[:schema]['$ref'].split('/').last if response[:schema].key?('$ref') - return response[:schema]['items']['$ref'].split('/').last if response[:schema].key?('items') + + response[:schema]['items']['$ref'].split('/').last if response[:schema].key?('items') end def add_extension_to(part, extensions) diff --git a/lib/grape-swagger/endpoint.rb b/lib/grape-swagger/endpoint.rb index 27e123dd..89afafea 100644 --- a/lib/grape-swagger/endpoint.rb +++ b/lib/grape-swagger/endpoint.rb @@ -413,7 +413,7 @@ def expose_params(value) end def expose_params_from_model(model) - model = model.is_a?(String) ? model.constantize : model + model = model.constantize if model.is_a?(String) model_name = model_name(model) return model_name if @definitions.key?(model_name)