grape-swagger 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.rubocop_todo.yml +1 -1
  4. data/CHANGELOG.md +24 -2
  5. data/Gemfile +5 -0
  6. data/README.md +105 -3
  7. data/example/api/endpoints.rb +16 -16
  8. data/lib/grape-swagger.rb +0 -1
  9. data/lib/grape-swagger/doc_methods.rb +1 -0
  10. data/lib/grape-swagger/doc_methods/data_type.rb +15 -3
  11. data/lib/grape-swagger/doc_methods/extensions.rb +16 -12
  12. data/lib/grape-swagger/doc_methods/move_params.rb +139 -94
  13. data/lib/grape-swagger/doc_methods/parse_params.rb +9 -7
  14. data/lib/grape-swagger/endpoint.rb +36 -17
  15. data/lib/grape-swagger/version.rb +1 -1
  16. data/spec/lib/data_type_spec.rb +24 -0
  17. data/spec/lib/endpoint_spec.rb +13 -0
  18. data/spec/lib/move_params_spec.rb +124 -116
  19. data/spec/support/model_parsers/entity_parser.rb +8 -2
  20. data/spec/support/model_parsers/mock_parser.rb +10 -0
  21. data/spec/support/model_parsers/representable_parser.rb +7 -0
  22. data/spec/support/the_paths_definitions.rb +1 -2
  23. data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +2 -1
  24. data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +1 -1
  25. data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +22 -1
  26. data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +4 -1
  27. data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +60 -0
  28. data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +14 -9
  29. data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +90 -0
  30. data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +185 -110
  31. data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +11 -13
  32. data/spec/swagger_v2/api_swagger_v2_response_spec.rb +5 -5
  33. data/spec/swagger_v2/endpoint_versioned_path_spec.rb +19 -18
  34. data/spec/swagger_v2/namespaced_api_spec.rb +20 -0
  35. data/spec/swagger_v2/param_multi_type_spec.rb +73 -0
  36. data/spec/swagger_v2/param_type_spec.rb +54 -27
  37. data/spec/swagger_v2/params_array_spec.rb +96 -6
  38. data/spec/swagger_v2/params_nested_spec.rb +2 -2
  39. metadata +9 -3
@@ -6,11 +6,9 @@ module GrapeSwagger
6
6
  path = route.path
7
7
  method = route.request_method
8
8
 
9
+ additional_documentation = settings.fetch(:documentation, {})
10
+ settings.merge!(additional_documentation)
9
11
  data_type = GrapeSwagger::DocMethods::DataType.call(settings)
10
- additional_documentation = settings[:documentation]
11
- if additional_documentation
12
- settings = additional_documentation.merge(settings)
13
- end
14
12
 
15
13
  value_type = settings.merge(data_type: data_type, path: path, param_name: param, method: method)
16
14
 
@@ -66,14 +64,18 @@ module GrapeSwagger
66
64
  if value_type[:is_array]
67
65
  if value_type[:documentation].present?
68
66
  param_type = value_type[:documentation][:param_type]
69
- type = GrapeSwagger::DocMethods::DataType.mapping(value_type[:documentation][:type])
67
+ doc_type = value_type[:documentation][:type]
68
+ type = GrapeSwagger::DocMethods::DataType.mapping(doc_type) if doc_type && !DataType.request_primitive?(doc_type)
70
69
  end
71
- array_items = { 'type' => type || value_type[:data_type] }
70
+
71
+ array_items = {
72
+ type: type || @parsed_param[:type],
73
+ format: @parsed_param.delete(:format)
74
+ }.delete_if { |_, value| value.blank? }
72
75
 
73
76
  @parsed_param[:in] = param_type || 'formData'
74
77
  @parsed_param[:items] = array_items
75
78
  @parsed_param[:type] = 'array'
76
- @parsed_param.delete(:format)
77
79
  end
78
80
  end
79
81
 
@@ -24,6 +24,7 @@ module Grape
24
24
  swagger: '2.0',
25
25
  produces: content_types_for(target_class),
26
26
  authorizations: options[:authorizations],
27
+ securityDefinitions: options[:security_definitions],
27
28
  host: GrapeSwagger::DocMethods::OptionalObject.build(:host, options, request),
28
29
  basePath: GrapeSwagger::DocMethods::OptionalObject.build(:base_path, options, request),
29
30
  tags: GrapeSwagger::DocMethods::TagNameDescription.build(options),
@@ -71,7 +72,6 @@ module Grape
71
72
  end
72
73
 
73
74
  add_definitions_from options[:models]
74
- GrapeSwagger::DocMethods::MoveParams.to_definition(@paths, @definitions)
75
75
  [@paths, @definitions]
76
76
  end
77
77
 
@@ -109,7 +109,7 @@ module Grape
109
109
  method[:consumes] = consumes_object(route, options[:format])
110
110
  method[:parameters] = params_object(route)
111
111
  method[:responses] = response_object(route, options[:markdown])
112
- method[:tags] = tag_object(route, options[:version].to_s)
112
+ method[:tags] = tag_object(route)
113
113
  method[:operationId] = GrapeSwagger::DocMethods::OperationId.build(route, path)
114
114
  method.delete_if { |_, value| value.blank? }
115
115
 
@@ -154,11 +154,17 @@ module Grape
154
154
  end
155
155
 
156
156
  def params_object(route)
157
- partition_params(route).map do |param, value|
157
+ parameters = partition_params(route).map do |param, value|
158
158
  value = { required: false }.merge(value) if value.is_a?(Hash)
159
159
  _, value = default_type([[param, value]]).first if value == ''
160
160
  GrapeSwagger::DocMethods::ParseParams.call(param, value, route)
161
161
  end
162
+
163
+ if GrapeSwagger::DocMethods::MoveParams.can_be_moved?(parameters, route.request_method)
164
+ parameters = GrapeSwagger::DocMethods::MoveParams.to_definition(parameters, route, @definitions)
165
+ end
166
+
167
+ parameters
162
168
  end
163
169
 
164
170
  def response_object(route, markdown)
@@ -194,8 +200,8 @@ module Grape
194
200
  end
195
201
  end
196
202
 
197
- def tag_object(route, version)
198
- Array(route.path.split('{')[0].split('/').reject(&:empty?).delete_if { |i| ((i == route.prefix.to_s) || (i == version)) }.first)
203
+ def tag_object(route)
204
+ Array(route.path.split('{')[0].split('/').reject(&:empty?).delete_if { |i| ((i == route.prefix.to_s) || (i == route.version)) }.first)
199
205
  end
200
206
 
201
207
  private
@@ -203,7 +209,7 @@ module Grape
203
209
  def partition_params(route)
204
210
  declared_params = route.settings[:declared_params] if route.settings[:declared_params].present?
205
211
  required, exposed = route.params.partition { |x| x.first.is_a? String }
206
- required.concat GrapeSwagger::DocMethods::Headers.parse(route) unless route.headers.nil?
212
+ required = GrapeSwagger::DocMethods::Headers.parse(route) + required unless route.headers.nil?
207
213
  default_type(required)
208
214
  default_type(exposed)
209
215
 
@@ -221,20 +227,25 @@ module Grape
221
227
  end
222
228
  end
223
229
 
224
- def parse_request_params(required)
225
- required.each_with_object({}) do |param, memo|
226
- @array_key = param.first.to_s.gsub('[', '[][') if param.last[:type] == 'Array'
227
- possible_key = param.first.to_s.gsub('[', '[][')
228
- if @array_key && possible_key.start_with?(@array_key)
229
- key = possible_key
230
- param.last[:is_array] = true
231
- else
232
- key = param.first
233
- end
234
- memo[key] = param.last unless param.last[:type] == 'Hash' || param.last[:type] == 'Array' && !param.last.key?(:documentation)
230
+ def parse_request_params(params)
231
+ array_key = nil
232
+ params.select { |param| public_parameter?(param) }.each_with_object({}) do |param, memo|
233
+ name, options = *param
234
+ array_key = name.to_s if param_type_is_array?(options[:type])
235
+ options[:is_array] = true if array_key && name.start_with?(array_key)
236
+ memo[param.first] = options unless (options[:type] == 'Hash' || options[:type] == 'Array') && !options.key?(:documentation)
235
237
  end
236
238
  end
237
239
 
240
+ def param_type_is_array?(param_type)
241
+ return false unless param_type
242
+ return true if param_type == 'Array'
243
+ param_types = param_type.match(/\[(.*)\]$/)
244
+ return false unless param_types
245
+ param_types = param_types[0].split(',') if param_types
246
+ param_types.size == 1
247
+ end
248
+
238
249
  def expose_params_from_model(model)
239
250
  model_name = model_name(model)
240
251
 
@@ -269,5 +280,13 @@ module Grape
269
280
  route_hidden = route_hidden.call if route_hidden.is_a?(Proc)
270
281
  route_hidden
271
282
  end
283
+
284
+ def public_parameter?(param)
285
+ param_options = param.last
286
+ return true unless param_options.key?(:documentation) && !param_options[:required]
287
+ param_hidden = param_options[:documentation].fetch(:hidden, false)
288
+ param_hidden = param_hidden.call if param_hidden.is_a?(Proc)
289
+ !param_hidden
290
+ end
272
291
  end
273
292
  end
@@ -1,3 +1,3 @@
1
1
  module GrapeSwagger
2
- VERSION = '0.21.0'.freeze
2
+ VERSION = '0.22.0'.freeze
3
3
  end
@@ -18,6 +18,18 @@ describe GrapeSwagger::DocMethods::DataType do
18
18
  it { expect(subject).to eql 'object' }
19
19
  end
20
20
 
21
+ describe 'Multi types in a string' do
22
+ let(:value) { { type: '[String, Integer]' } }
23
+
24
+ it { expect(subject).to eql 'string' }
25
+ end
26
+
27
+ describe 'Multi types in array' do
28
+ let(:value) { { type: [String, Integer] } }
29
+
30
+ it { expect(subject).to eql 'string' }
31
+ end
32
+
21
33
  describe 'Rack::Multipart::UploadedFile' do
22
34
  let(:value) { { type: Rack::Multipart::UploadedFile } }
23
35
 
@@ -53,4 +65,16 @@ describe GrapeSwagger::DocMethods::DataType do
53
65
 
54
66
  it { expect(subject).to eql 'string' }
55
67
  end
68
+
69
+ describe '[String]' do
70
+ let(:value) { { type: '[String]' } }
71
+
72
+ it { expect(subject).to eq('string') }
73
+ end
74
+
75
+ describe '[Integer]' do
76
+ let(:value) { { type: '[Integer]' } }
77
+
78
+ it { expect(subject).to eq('integer') }
79
+ end
56
80
  end
@@ -2,4 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  describe Grape::Endpoint do
4
4
  subject { described_class.new(Grape::Util::InheritableSetting.new, path: '/', method: :get) }
5
+
6
+ describe '#param_type_is_array?' do
7
+ it 'returns true if the value passed represents an array' do
8
+ expect(subject.send(:param_type_is_array?, 'Array')).to be_truthy
9
+ expect(subject.send(:param_type_is_array?, '[String]')).to be_truthy
10
+ expect(subject.send(:param_type_is_array?, 'Array[Integer]')).to be_truthy
11
+ end
12
+
13
+ it 'returns false if the value passed does not represent an array' do
14
+ expect(subject.send(:param_type_is_array?, 'String')).to be_falsey
15
+ expect(subject.send(:param_type_is_array?, '[String, Integer]')).to be_falsey
16
+ end
17
+ end
5
18
  end
@@ -7,86 +7,141 @@ describe GrapeSwagger::DocMethods::MoveParams do
7
7
 
8
8
  it { expect(subject.to_s).to eql 'GrapeSwagger::DocMethods::MoveParams' }
9
9
 
10
- describe 'find_post_put' do
11
- let(:paths) { {} }
10
+ describe 'parameters can_be_moved' do
11
+ let(:movable_params) do
12
+ [
13
+ { param_type: 'path', name: 'key', description: nil, type: 'integer', format: 'int32', required: true },
14
+ { param_type: 'body', name: 'in_body', description: 'in_body', type: 'integer', format: 'int32', required: true },
15
+ { param_type: 'query', name: 'in_query', description: 'in_query', type: 'integer', format: 'int32', required: true },
16
+ { param_type: 'header', name: 'in_header', description: 'in_header', type: 'integer', format: 'int32', required: true },
17
+ { param_type: 'formData', name: 'in_form_data', description: 'in_form_data', type: 'integer', format: 'int32', required: true }
18
+ ]
19
+ end
12
20
 
13
- describe 'paths empty' do
14
- specify { expect { |b| subject.find_post_put(paths, &b) }.not_to yield_control }
21
+ let(:not_movable_params) do
22
+ [
23
+ { in: 'path', name: 'key', description: nil, type: 'integer', format: 'int32', required: true },
24
+ { in: 'query', name: 'in_query', description: 'in_query', type: 'integer', format: 'int32', required: true },
25
+ { in: 'header', name: 'in_header', description: 'in_header', type: 'integer', format: 'int32', required: true },
26
+ { in: 'formData', name: 'in_form_data', description: 'in_form_data', type: 'integer', format: 'int32', required: true }
27
+ ]
15
28
  end
16
29
 
17
- describe 'no post/put given' do
18
- let(:paths) do
19
- {
20
- :'/foo' => { get: {}, delete: {} },
21
- :'/bar/{key}' => { get: {}, delete: {} }
22
- }
30
+ let(:allowed_verbs) do
31
+ [:post, :put, :patch, 'POST', 'PUT', 'PATCH']
32
+ end
33
+
34
+ let(:not_allowed_verbs) do
35
+ [:get, :delete, 'GET', 'DELETE']
36
+ end
37
+
38
+ describe 'movable params' do
39
+ specify 'allowed verbs' do
40
+ allowed_verbs.each do |verb|
41
+ expect(subject.can_be_moved?(movable_params, verb)).to be true
42
+ end
43
+ end
44
+
45
+ specify 'not allowed verbs' do
46
+ not_allowed_verbs.each do |verb|
47
+ expect(subject.can_be_moved?(movable_params, verb)).to be false
48
+ end
23
49
  end
24
- specify { expect { |b| subject.find_post_put(paths, &b) }.not_to yield_control }
25
50
  end
26
51
 
27
- describe 'no post/put given' do
28
- let(:paths) do
29
- {
30
- :'/foo' => { get: {}, delete: {}, post: {}, put: {}, patch: {} },
31
- :'/bar/{key}' => { get: {}, delete: {}, post: {}, put: {}, patch: {} }
32
- }
52
+ describe 'not movable params' do
53
+ specify 'allowed verbs' do
54
+ allowed_verbs.each do |verb|
55
+ expect(subject.can_be_moved?(not_movable_params, verb)).to be false
56
+ end
57
+ end
58
+
59
+ specify 'not allowed verbs' do
60
+ not_allowed_verbs.each do |verb|
61
+ expect(subject.can_be_moved?(not_movable_params, verb)).to be false
62
+ end
63
+ end
64
+ end
65
+
66
+ describe 'movable_params' do
67
+ before do
68
+ subject.send(:unify!, movable_params)
33
69
  end
34
- let(:expected) do
70
+ let(:expected_params) do
35
71
  [
36
- { post: {}, put: {}, patch: {} },
37
- { post: {}, put: {}, patch: {} }
72
+ { in: 'path', name: 'key', description: nil, type: 'integer', format: 'int32', required: true },
73
+ { in: 'query', name: 'in_query', description: 'in_query', type: 'integer', format: 'int32', required: true },
74
+ { in: 'header', name: 'in_header', description: 'in_header', type: 'integer', format: 'int32', required: true }
75
+ ]
76
+ end
77
+
78
+ let(:expected_movable_params) do
79
+ [
80
+ { in: 'body', name: 'in_body', description: 'in_body', type: 'integer', format: 'int32', required: true },
81
+ { in: 'body', name: 'in_form_data', description: 'in_form_data', type: 'integer', format: 'int32', required: true }
38
82
  ]
39
83
  end
40
- specify { expect { |b| subject.find_post_put(paths, &b) }.to yield_control.twice }
41
- specify { expect { |b| subject.find_post_put(paths, &b) }.to yield_successive_args *expected }
42
- end
43
- end
44
84
 
45
- describe 'find_definition_and_params' do
46
- specify do
47
- subject.instance_variable_set(:@definitions, definitions)
48
- subject.find_definition_and_params(found_path, :post)
49
- expect(definitions.keys).to include 'InBody'
85
+ specify do
86
+ params_to_move = subject.send(:movable_params, movable_params)
87
+ expect(movable_params).to eql expected_params
88
+ expect(params_to_move).to eql expected_movable_params
89
+ end
50
90
  end
51
91
  end
52
92
 
53
- describe 'move_params_to_new definition' do
54
- let(:name) { 'Foo' }
55
- let(:definitions) { {} }
56
-
57
- describe 'post request' do
58
- let(:verb) { 'post' }
93
+ describe 'parent_definition_of_params' do
94
+ describe 'POST' do
59
95
  let(:params) { paths['/in_body'][:post][:parameters] }
96
+ let(:options) do
97
+ {
98
+ method: 'POST'
99
+ }
100
+ end
101
+ let(:env) { Rack::MockRequest.env_for('/in_body', options) }
102
+ let(:request) { Grape::Request.new(env) }
60
103
 
61
104
  specify do
62
- subject.instance_variable_set(:@definitions, definitions)
63
- name = subject.send(:build_definition, name, verb)
64
- subject.move_params_to_new(name, params)
65
-
66
- expect(definitions[name]).to eql expected_post_defs
67
- expect(params).to be_empty
105
+ subject.to_definition(params, request, definitions)
106
+ expect(params).to eql(
107
+ [
108
+ { name: 'InBody', in: 'body', required: true, schema: { '$ref' => '#/definitions/postInBody' } }
109
+ ]
110
+ )
111
+ expect(subject.definitions['postInBody']).not_to include :description
112
+ expect(subject.definitions['postInBody']).to eql expected_post_defs
68
113
  end
69
114
  end
70
115
 
71
- describe 'put request' do
72
- let(:verb) { 'put' }
116
+ describe 'POST' do
73
117
  let(:params) { paths['/in_body/{key}'][:put][:parameters] }
118
+ let(:options) do
119
+ {
120
+ method: 'PUT'
121
+ }
122
+ end
123
+ let(:env) { Rack::MockRequest.env_for('/in_body', options) }
124
+ let(:request) { Grape::Request.new(env) }
74
125
 
75
126
  specify do
76
- subject.instance_variable_set(:@definitions, definitions)
77
- name, definition = subject.send(:build_definition, name, verb)
78
- subject.move_params_to_new(name, params)
79
-
80
- expect(definitions[name]).to eql expected_put_defs
81
- expect(params.length).to be 1
127
+ subject.to_definition(params, request, definitions)
128
+ expect(params).to eql(
129
+ [
130
+ { in: 'path', name: 'key', description: nil, type: 'integer', format: 'int32', required: true },
131
+ { name: 'InBody', in: 'body', required: true, schema: { '$ref' => '#/definitions/putInBody' } }
132
+ ]
133
+ )
134
+ expect(subject.definitions['putInBody']).not_to include :description
135
+ expect(subject.definitions['putInBody']).to eql expected_put_defs
82
136
  end
83
137
  end
84
138
  end
85
139
 
86
140
  describe 'nested definitions related' do
87
141
  describe 'prepare_nested_names' do
142
+ let(:property) { 'address' }
88
143
  before do
89
- subject.send(:prepare_nested_names, params)
144
+ subject.send(:prepare_nested_names, property, params)
90
145
  end
91
146
 
92
147
  describe 'simple' do
@@ -106,8 +161,8 @@ describe GrapeSwagger::DocMethods::MoveParams do
106
161
  end
107
162
 
108
163
  describe 'array' do
109
- let(:params) { [{ in: 'body', name: 'address[][street_lines]', description: 'street lines', type: 'array', required: true }] }
110
- let(:expected) { [{ in: 'body', name: 'street_lines', description: 'street lines', type: 'array', required: true }] }
164
+ let(:params) { [{ in: 'body', name: 'address[street_lines]', description: 'street lines', type: 'array', items: { type: 'string' }, required: true }] }
165
+ let(:expected) { [{ in: 'body', name: 'street_lines', description: 'street lines', type: 'array', items: { type: 'string' }, required: true }] }
111
166
  specify do
112
167
  expect(params).to eql expected
113
168
  end
@@ -117,9 +172,10 @@ describe GrapeSwagger::DocMethods::MoveParams do
117
172
 
118
173
  describe 'private methods' do
119
174
  describe 'build_definition' do
175
+ let(:params) { [{ in: 'body', name: 'address[street][name]', description: 'street', type: 'string', required: true }] }
120
176
  before do
121
177
  subject.instance_variable_set(:@definitions, definitions)
122
- subject.send(:build_definition, name, verb)
178
+ subject.send(:build_definition, name, params, verb)
123
179
  end
124
180
 
125
181
  describe 'verb given' do
@@ -129,8 +185,8 @@ describe GrapeSwagger::DocMethods::MoveParams do
129
185
 
130
186
  specify do
131
187
  definition = definitions.to_a.first
132
- expect(definition.first).to eql 'postRequestFoo'
133
- expect(definition.last).to eql(type: 'object', properties: {}, required: [])
188
+ expect(definition.first).to eql 'postFoo'
189
+ expect(definition.last).to eql(type: 'object', properties: {})
134
190
  end
135
191
  end
136
192
 
@@ -142,32 +198,20 @@ describe GrapeSwagger::DocMethods::MoveParams do
142
198
  specify do
143
199
  definition = definitions.to_a.first
144
200
  expect(definition.first).to eql 'FooBar'
145
- expect(definition.last).to eql(type: 'object', properties: {}, required: [])
201
+ expect(definition.last).to eql(type: 'object', properties: {})
146
202
  end
147
203
  end
148
204
  end
149
205
 
150
206
  describe 'build_body_parameter' do
151
- let(:response) { { schema: { '$ref' => '#/definitions/Somewhere' } } }
152
-
153
- describe 'no name given' do
154
- let(:name) { nil }
155
- let(:expected_param) do
156
- { name: 'Somewhere', in: 'body', required: true, schema: { '$ref' => '#/definitions/Somewhere' } }
157
- end
158
- specify do
159
- parameter = subject.send(:build_body_parameter, response)
160
- expect(parameter).to eql expected_param
161
- end
162
- end
163
-
164
207
  describe 'name given' do
165
208
  let(:name) { 'Foo' }
209
+ let(:reference) { 'Bar' }
166
210
  let(:expected_param) do
167
- { name: 'Somewhere', in: 'body', required: true, schema: { '$ref' => "#/definitions/#{name}" } }
211
+ { name: name, in: 'body', required: true, schema: { '$ref' => "#/definitions/#{reference}" } }
168
212
  end
169
213
  specify do
170
- parameter = subject.send(:build_body_parameter, response, name)
214
+ parameter = subject.send(:build_body_parameter, reference, name)
171
215
  expect(parameter).to eql expected_param
172
216
  end
173
217
  end
@@ -175,30 +219,17 @@ describe GrapeSwagger::DocMethods::MoveParams do
175
219
 
176
220
  describe 'parse_model' do
177
221
  let(:ref) { '#/definitions/InBody' }
178
- subject(:object) { described_class.send(:parse_model, ref) }
179
-
180
- specify { expect(object).to eql 'InBody' }
181
- end
182
-
183
- describe 'movable' do
184
- describe 'path' do
185
- let(:param) { { in: 'path', name: 'key', description: nil, type: 'integer', format: 'int32', required: true } }
186
- it { expect(subject.send(:movable?, param)).to be true }
187
- end
222
+ describe 'post request' do
223
+ subject(:object) { described_class.send(:parse_model, ref) }
188
224
 
189
- describe 'body' do
190
- let(:param) { { in: 'body', name: 'in_body', description: 'in_body', type: 'integer', format: 'int32', required: true } }
191
- it { expect(subject.send(:movable?, param)).to be true }
225
+ specify { expect(object).to eql ref }
192
226
  end
193
227
 
194
- describe 'query' do
195
- let(:param) { { in: 'query', name: 'in_query', description: 'in_query', type: 'integer', format: 'int32', required: true } }
196
- it { expect(subject.send(:movable?, param)).to be false }
197
- end
228
+ describe 'post request' do
229
+ let(:put_ref) { '#/definitions/InBody/{id}' }
230
+ subject(:object) { described_class.send(:parse_model, put_ref) }
198
231
 
199
- describe 'header' do
200
- let(:param) { { in: 'header', name: 'in_header', description: 'in_header', type: 'integer', format: 'int32', required: true } }
201
- it { expect(subject.send(:movable?, param)).to be false }
232
+ specify { expect(object).to eql ref }
202
233
  end
203
234
  end
204
235
 
@@ -224,32 +255,9 @@ describe GrapeSwagger::DocMethods::MoveParams do
224
255
  end
225
256
  end
226
257
 
227
- describe 'should move' do
228
- describe 'no move' do
229
- let(:params) do
230
- [
231
- { in: 'path', name: 'key', description: nil, type: 'integer', format: 'int32', required: true },
232
- { in: 'formData', name: 'in_form_data', description: 'in_form_data', type: 'integer', format: 'int32', required: true }
233
- ]
234
- end
235
- it { expect(subject.send(:should_move?, params)).to be false }
236
- end
237
-
238
- describe 'move' do
239
- let(:params) do
240
- [
241
- { in: 'path', name: 'key', description: nil, type: 'integer', format: 'int32', required: true },
242
- { in: 'body', name: 'in_bosy', description: 'in_bosy', type: 'integer', format: 'int32', required: true },
243
- { in: 'formData', name: 'in_form_data', description: 'in_form_data', type: 'integer', format: 'int32', required: true }
244
- ]
245
- end
246
- it { expect(subject.send(:should_move?, params)).to be true }
247
- end
248
- end
249
-
250
258
  describe 'unify' do
251
- before do
252
- subject.send(:unify!, params) if subject.send(:should_move?, params)
259
+ before :each do
260
+ subject.send(:unify!, params)
253
261
  end
254
262
  describe 'param type with `:in` given' do
255
263
  let(:params) do