grape-swagger 0.30.1 → 0.31.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,67 +3,84 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'nested group params' do
6
- def app
7
- Class.new(Grape::API) do
8
- format :json
6
+ [true, false].each do |array_use_braces|
7
+ context "when array_use_braces option is set to #{array_use_braces}" do
8
+ let(:braces) { array_use_braces ? '[]' : '' }
9
+ let(:app) do
10
+ Class.new(Grape::API) do
11
+ format :json
9
12
 
10
- params do
11
- requires :a_array, type: Array do
12
- requires :param_1, type: Integer
13
- requires :b_array, type: Array do
14
- requires :param_2, type: String
13
+ params do
14
+ requires :a_array, type: Array do
15
+ requires :param_1, type: Integer
16
+ requires :b_array, type: Array do
17
+ requires :param_2, type: String
18
+ end
19
+ requires :c_hash, type: Hash do
20
+ requires :param_3, type: String
21
+ end
22
+ end
23
+ requires :a_array_foo, type: String
24
+ end
25
+ post '/nested_array' do
26
+ { 'declared_params' => declared(params) }
15
27
  end
16
- end
17
- end
18
- post '/nested_array' do
19
- { 'declared_params' => declared(params) }
20
- end
21
28
 
22
- params do
23
- requires :a_hash, type: Hash do
24
- requires :param_1, type: Integer
25
- requires :b_hash, type: Hash do
26
- requires :param_2, type: String
29
+ params do
30
+ requires :a_hash, type: Hash do
31
+ requires :param_1, type: Integer
32
+ requires :b_hash, type: Hash do
33
+ requires :param_2, type: String
34
+ end
35
+ requires :c_array, type: Array do
36
+ requires :param_3, type: String
37
+ end
38
+ end
39
+ requires :a_hash_foo, type: String
40
+ end
41
+ post '/nested_hash' do
42
+ { 'declared_params' => declared(params) }
27
43
  end
44
+
45
+ add_swagger_documentation array_use_braces: array_use_braces
28
46
  end
29
47
  end
30
- post '/nested_hash' do
31
- { 'declared_params' => declared(params) }
32
- end
33
-
34
- add_swagger_documentation
35
- end
36
- end
37
48
 
38
- describe 'retrieves the documentation for nested array parameters' do
39
- subject do
40
- get '/swagger_doc/nested_array'
41
- JSON.parse(last_response.body)
42
- end
49
+ describe 'retrieves the documentation for nested array parameters' do
50
+ subject do
51
+ get '/swagger_doc/nested_array'
52
+ JSON.parse(last_response.body)
53
+ end
43
54
 
44
- specify do
45
- expect(subject['paths']['/nested_array']['post']['parameters']).to eql(
46
- [
47
- { 'in' => 'formData', 'name' => 'a_array[param_1]', 'required' => true, 'type' => 'array', 'items' => { 'type' => 'integer', 'format' => 'int32' } },
48
- { 'in' => 'formData', 'name' => 'a_array[b_array][param_2]', 'required' => true, 'type' => 'array', 'items' => { 'type' => 'string' } }
49
- ]
50
- )
51
- end
52
- end
55
+ specify do
56
+ expect(subject['paths']['/nested_array']['post']['parameters']).to eql(
57
+ [
58
+ { 'in' => 'formData', 'name' => "a_array#{braces}[param_1]", 'required' => true, 'type' => 'array', 'items' => { 'type' => 'integer', 'format' => 'int32' } },
59
+ { 'in' => 'formData', 'name' => "a_array#{braces}[b_array]#{braces}[param_2]", 'required' => true, 'type' => 'array', 'items' => { 'type' => 'string' } },
60
+ { 'in' => 'formData', 'name' => "a_array#{braces}[c_hash][param_3]", 'required' => true, 'type' => 'array', 'items' => { 'type' => 'string' } },
61
+ { 'in' => 'formData', 'name' => 'a_array_foo', 'required' => true, 'type' => 'string' }
62
+ ]
63
+ )
64
+ end
65
+ end
53
66
 
54
- describe 'retrieves the documentation for nested hash parameters' do
55
- subject do
56
- get '/swagger_doc/nested_hash'
57
- JSON.parse(last_response.body)
58
- end
67
+ describe 'retrieves the documentation for nested hash parameters' do
68
+ subject do
69
+ get '/swagger_doc/nested_hash'
70
+ JSON.parse(last_response.body)
71
+ end
59
72
 
60
- specify do
61
- expect(subject['paths']['/nested_hash']['post']['parameters']).to eql(
62
- [
63
- { 'in' => 'formData', 'name' => 'a_hash[param_1]', 'required' => true, 'type' => 'integer', 'format' => 'int32' },
64
- { 'in' => 'formData', 'name' => 'a_hash[b_hash][param_2]', 'required' => true, 'type' => 'string' }
65
- ]
66
- )
73
+ specify do
74
+ expect(subject['paths']['/nested_hash']['post']['parameters']).to eql(
75
+ [
76
+ { 'in' => 'formData', 'name' => 'a_hash[param_1]', 'required' => true, 'type' => 'integer', 'format' => 'int32' },
77
+ { 'in' => 'formData', 'name' => 'a_hash[b_hash][param_2]', 'required' => true, 'type' => 'string' },
78
+ { 'in' => 'formData', 'name' => "a_hash[c_array]#{braces}[param_3]", 'required' => true, 'type' => 'array', 'items' => { 'type' => 'string' } },
79
+ { 'in' => 'formData', 'name' => 'a_hash_foo', 'required' => true, 'type' => 'string' }
80
+ ]
81
+ )
82
+ end
83
+ end
67
84
  end
68
85
  end
69
86
  end
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: 0.30.1
4
+ version: 0.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Vandecasteele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-19 00:00:00.000000000 Z
11
+ date: 2018-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -70,6 +70,7 @@ files:
70
70
  - lib/grape-swagger/doc_methods/tag_name_description.rb
71
71
  - lib/grape-swagger/doc_methods/version.rb
72
72
  - lib/grape-swagger/endpoint.rb
73
+ - lib/grape-swagger/endpoint/params_parser.rb
73
74
  - lib/grape-swagger/errors.rb
74
75
  - lib/grape-swagger/model_parsers.rb
75
76
  - lib/grape-swagger/rake/oapi_tasks.rb
@@ -92,6 +93,7 @@ files:
92
93
  - spec/issues/650_params_array_spec.rb
93
94
  - spec/issues/680_keep_204_error_schemas_spec.rb
94
95
  - spec/lib/data_type_spec.rb
96
+ - spec/lib/endpoint/params_parser_spec.rb
95
97
  - spec/lib/endpoint_spec.rb
96
98
  - spec/lib/extensions_spec.rb
97
99
  - spec/lib/model_parsers_spec.rb
@@ -186,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
188
  version: '0'
187
189
  requirements: []
188
190
  rubyforge_project:
189
- rubygems_version: 2.7.6
191
+ rubygems_version: 2.7.7
190
192
  signing_key:
191
193
  specification_version: 4
192
194
  summary: Add auto generated documentation to your Grape API that can be displayed
@@ -210,6 +212,7 @@ test_files:
210
212
  - spec/issues/650_params_array_spec.rb
211
213
  - spec/issues/680_keep_204_error_schemas_spec.rb
212
214
  - spec/lib/data_type_spec.rb
215
+ - spec/lib/endpoint/params_parser_spec.rb
213
216
  - spec/lib/endpoint_spec.rb
214
217
  - spec/lib/extensions_spec.rb
215
218
  - spec/lib/model_parsers_spec.rb