grape-swagger 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eae164875a188218b1eb4e0e3a53039f8e661f3dd115b4cc9a6f415b3a92e64b
4
- data.tar.gz: 6962782ea370ff7b4f84c62ed77f2fe1e7232332f3a238bce4c5af5b62eb1534
3
+ metadata.gz: 8ced0e59624b64b14e517815c13c6761c970da13cfd7e6d5c82493b1bb49c815
4
+ data.tar.gz: a5891f3a10dc5e3ae96bb1f295dcf1978f0758175160b1681ba5f85f0b7cc206
5
5
  SHA512:
6
- metadata.gz: 8b56b026ba97a2308579737c43daf0e9f619df0c91c511e424b533f99105faec83f9ddbcb3dd2f3d98866bffdbdecb13e652f302424f54ec4095c4605405319c
7
- data.tar.gz: 2e88c630ade44d4c9395a18e690cad717f5a6ba6e6daae81624d0b7e6347f06c9d7d07ce85f16b5eb99ea25c1a716127cd8aac17c1367823ded3bd84151dbc47
6
+ metadata.gz: 61c9297050672b095bf2ab8a6648420b6226fa5ecaa2b1b2df07e99c271dba4f1fe9547a77eae5dc4e1b5d0b29035f823e389957b57149f4fb79cf3187597ee9
7
+ data.tar.gz: 55f926c09f83bfe6e0ab15caeac329acf6f6d623d9c579b89c872fdd2f11f5ddece4e0a74259f921688bcf8e2255fecd908fce3f2eb4b2b58ed449803d3c2900
@@ -30,6 +30,9 @@ Layout/SpaceAroundMethodCallOperator:
30
30
  Lint/DeprecatedOpenSSLConstant:
31
31
  Enabled: true
32
32
 
33
+ Lint/DuplicateElsifCondition:
34
+ Enabled: true
35
+
33
36
  Lint/MixedRegexpCaptureTypes:
34
37
  Enabled: true
35
38
 
@@ -62,12 +65,29 @@ Naming:
62
65
 
63
66
  # Style stuff
64
67
  #
68
+ Style/AccessorGrouping:
69
+ Enabled: true
70
+
71
+ Style/ArrayCoercion:
72
+ Enabled: true
73
+
74
+ Style/BisectedAttrAccessor:
75
+ Enabled: true
76
+
77
+ Style/CaseLikeIf:
78
+ Enabled: true
79
+
65
80
  Style/ExponentialNotation:
66
81
  Enabled: true
67
82
 
83
+ Style/HashAsLastArrayItem:
84
+ Enabled: true
68
85
  Style/HashEachMethods:
69
86
  Enabled: true
70
87
 
88
+ Style/HashLikeCase:
89
+ Enabled: true
90
+
71
91
  Style/HashTransformKeys:
72
92
  Enabled: true
73
93
 
@@ -77,9 +97,15 @@ Style/HashTransformValues:
77
97
  Style/RegexpLiteral:
78
98
  Enabled: false
79
99
 
100
+ Style/RedundantAssignment:
101
+ Enabled: true
102
+
80
103
  Style/RedundantFetchBlock:
81
104
  Enabled: true
82
105
 
106
+ Style/RedundantFileExtensionInRequire:
107
+ Enabled: true
108
+
83
109
  Style/RedundantRegexpCharacterClass:
84
110
  Enabled: true
85
111
 
@@ -88,3 +114,5 @@ Style/RedundantRegexpEscape:
88
114
 
89
115
  Style/SlicingWithRange:
90
116
  Enabled: false
117
+
118
+
@@ -13,9 +13,10 @@ rvm:
13
13
  - 2.6.6
14
14
  - 2.7.1
15
15
  env:
16
- - GRAPE_VERSION=1.3.0 MODEL_PARSER=grape-swagger-entity
17
- - GRAPE_VERSION=1.3.0 MODEL_PARSER=grape-swagger-representable
18
- - GRAPE_VERSION=1.3.0
16
+ - GRAPE_VERSION=1.3.3
17
+ - GRAPE_VERSION=1.4.0 MODEL_PARSER=grape-swagger-entity
18
+ - GRAPE_VERSION=1.4.0 MODEL_PARSER=grape-swagger-representable
19
+ - GRAPE_VERSION=1.4.0
19
20
  - GRAPE_VERSION=HEAD
20
21
 
21
22
  jobs:
@@ -33,5 +34,3 @@ jobs:
33
34
  - rvm: 2.4.10
34
35
  - rvm: ruby-head
35
36
  - rvm: jruby-head
36
-
37
- - env: GRAPE_VERSION=HEAD
@@ -9,6 +9,13 @@
9
9
  * Your contribution here.
10
10
 
11
11
 
12
+ ### 1.2.1 (July 15, 2020)
13
+
14
+ #### Fixes
15
+
16
+ * [#801](https://github.com/ruby-grape/grape-swagger/pull/801): Fixes behaviour after grape upgrade to 1.4.0 - [@LeFnord](https://github.com/LeFnord).
17
+
18
+
12
19
  ### 1.2.0 (July 1, 2020)
13
20
 
14
21
  #### Features
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ ruby RUBY_VERSION
6
6
 
7
7
  gemspec
8
8
 
9
- gem 'grape', case version = ENV['GRAPE_VERSION'] || '>= 1.3.0'
9
+ gem 'grape', case version = ENV['GRAPE_VERSION'] || '>= 1.4.0'
10
10
  when 'HEAD'
11
11
  { git: 'https://github.com/ruby-grape/grape' }
12
12
  else
@@ -27,7 +27,7 @@ group :development, :test do
27
27
  gem 'rake'
28
28
  gem 'rdoc'
29
29
  gem 'rspec', '~> 3.9'
30
- gem 'rubocop', '~> 0.85', require: false
30
+ gem 'rubocop', '~> 0.88', require: false
31
31
  end
32
32
 
33
33
  group :test do
@@ -107,8 +107,7 @@ module SwaggerRouting
107
107
  end
108
108
 
109
109
  module SwaggerDocumentationAdder
110
- attr_accessor :combined_namespaces, :combined_namespace_identifiers
111
- attr_accessor :combined_routes, :combined_namespace_routes
110
+ attr_accessor :combined_namespaces, :combined_namespace_identifiers, :combined_routes, :combined_namespace_routes
112
111
 
113
112
  include SwaggerRouting
114
113
 
@@ -175,15 +175,18 @@ module Grape
175
175
  end
176
176
 
177
177
  def params_object(route, options, path)
178
- parameters = partition_params(route, options).map do |param, value|
178
+ parameters = build_request_params(route, options).each_with_object([]) do |(param, value), memo|
179
+ next if hidden_parameter?(value)
180
+
179
181
  value = { required: false }.merge(value) if value.is_a?(Hash)
180
182
  _, value = default_type([[param, value]]).first if value == ''
183
+
181
184
  if value.dig(:documentation, :type)
182
185
  expose_params(value[:documentation][:type])
183
186
  elsif value[:type]
184
187
  expose_params(value[:type])
185
188
  end
186
- GrapeSwagger::DocMethods::ParseParams.call(param, value, path, route, @definitions)
189
+ memo << GrapeSwagger::DocMethods::ParseParams.call(param, value, path, route, @definitions)
187
190
  end
188
191
 
189
192
  if GrapeSwagger::DocMethods::MoveParams.can_be_moved?(route.request_method, parameters)
@@ -253,7 +256,7 @@ module Grape
253
256
 
254
257
  def tag_object(route, path)
255
258
  version = GrapeSwagger::DocMethods::Version.get(route)
256
- version = [version] unless version.is_a?(Array)
259
+ version = Array(version)
257
260
  prefix = route.prefix.to_s.split('/').reject(&:empty?)
258
261
  Array(
259
262
  path.split('{')[0].split('/').reject(&:empty?).delete_if do |i|
@@ -296,16 +299,13 @@ module Grape
296
299
  memo['schema'] = { type: 'file' }
297
300
  end
298
301
 
299
- def partition_params(route, settings)
300
- declared_params = route.settings[:declared_params] if route.settings[:declared_params].present?
302
+ def build_request_params(route, settings)
301
303
  required = merge_params(route)
302
304
  required = GrapeSwagger::DocMethods::Headers.parse(route) + required unless route.headers.nil?
303
305
 
304
306
  default_type(required)
305
307
 
306
- request_params = unless declared_params.nil? && route.headers.nil?
307
- GrapeSwagger::Endpoint::ParamsParser.parse_request_params(required, settings, self)
308
- end || {}
308
+ request_params = GrapeSwagger::Endpoint::ParamsParser.parse_request_params(required, settings, self)
309
309
 
310
310
  request_params.empty? ? required : request_params
311
311
  end
@@ -363,6 +363,16 @@ module Grape
363
363
  options[:token_owner] ? route_hidden.call(send(options[:token_owner].to_sym)) : route_hidden.call
364
364
  end
365
365
 
366
+ def hidden_parameter?(value)
367
+ return false if value.dig(:required)
368
+
369
+ if value.dig(:documentation, :hidden).is_a?(Proc)
370
+ value.dig(:documentation, :hidden).call
371
+ else
372
+ value.dig(:documentation, :hidden)
373
+ end
374
+ end
375
+
366
376
  def success_code_from_entity(route, entity)
367
377
  default_code = GrapeSwagger::DocMethods::StatusCodes.get[route.request_method.downcase.to_sym]
368
378
  if entity.is_a?(Hash)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GrapeSwagger
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.1'
5
5
  end
@@ -5,8 +5,7 @@ end
5
5
 
6
6
  module GrapeSwagger
7
7
  class EmptyModelParser
8
- attr_reader :model
9
- attr_reader :endpoint
8
+ attr_reader :model, :endpoint
10
9
 
11
10
  def initialize(model, endpoint)
12
11
  @model = model
@@ -2,8 +2,7 @@
2
2
 
3
3
  module GrapeSwagger
4
4
  class MockParser
5
- attr_reader :model
6
- attr_reader :endpoint
5
+ attr_reader :model, :endpoint
7
6
 
8
7
  def initialize(model, endpoint)
9
8
  @model = model
@@ -19,7 +19,7 @@ describe 'hidden flag enables a single endpoint parameter to be excluded from th
19
19
  requires :name, type: String, documentation: { desc: 'name' }
20
20
  optional :favourite_color, type: String, documentation: { desc: 'I should not be anywhere', hidden: true }
21
21
  optional :proc_param, type: String, documentation: { desc: 'I should not be anywhere', hidden: proc { true } }
22
- optional :proc_with_token, type: String, documentation: { desc: 'I may be somewhere', hidden: proc { |token_owner = nil| token_owner.nil? } }
22
+ optional :proc_with_token, type: String, documentation: { desc: 'I may be somewhere', hidden: proc { false } }
23
23
  end
24
24
 
25
25
  post do
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe 'security requirement on endpoint method' do
6
6
  def app
7
7
  Class.new(Grape::API) do
8
- desc 'Endpoint with security requirement', security: [oauth_pets: ['read:pets', 'write:pets']]
8
+ desc 'Endpoint with security requirement', security: [{ oauth_pets: ['read:pets', 'write:pets'] }]
9
9
  get '/with_security' do
10
10
  { foo: 'bar' }
11
11
  end
@@ -37,7 +37,7 @@ describe 'security requirement on endpoint method' do
37
37
  end
38
38
 
39
39
  it 'defines the security requirement on the endpoint method' do
40
- expect(subject['paths']['/with_security']['get']['security']).to eql ['oauth_pets' => ['read:pets', 'write:pets']]
40
+ expect(subject['paths']['/with_security']['get']['security']).to eql [{ 'oauth_pets' => ['read:pets', 'write:pets'] }]
41
41
  end
42
42
 
43
43
  it 'defines an empty security requirement on the endpoint method' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-swagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Vandecasteele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-01 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
197
  requirements: []
198
- rubygems_version: 3.1.2
198
+ rubygems_version: 3.1.4
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Add auto generated documentation to your Grape API that can be displayed