@@ -61,7 +61,7 @@ class SimpleMountedApi < Grape::API
61
61
'custom' => { type : CustomType , description : 'array of items' , is_array : true }
62
62
}
63
63
64
- get '/custom' do
64
+ post '/custom' do
65
65
{ }
66
66
end
67
67
end
@@ -171,14 +171,26 @@ def app
171
171
}
172
172
} ,
173
173
'/custom' => {
174
- 'get ' => {
174
+ 'post ' => {
175
175
'description' => 'this uses a custom parameter' ,
176
- 'operationId' => 'getCustom' ,
177
- 'responses' => { '200' => {
178
- 'content' => { 'application/json' => { } } ,
179
- 'description' => 'this uses a custom parameter'
180
- } } ,
181
- 'tags' => [ 'custom' ]
176
+ 'operationId' => 'postCustom' ,
177
+ 'requestBody' => {
178
+ 'content' => {
179
+ 'application/json' => { 'schema' => { 'properties' => { } , 'type' => 'object' } } ,
180
+ 'application/x-www-form-urlencoded' => {
181
+ 'schema' => {
182
+ 'properties' => {
183
+ 'custom' => {
184
+ 'description' => 'array of items' ,
185
+ 'items' => { 'type' => 'CustomType' } ,
186
+ 'type' => 'array'
187
+ }
188
+ } ,
189
+ 'type' => 'object'
190
+ }
191
+ }
192
+ }
193
+ } , 'responses' => { '201' => { 'description' => 'this uses a custom parameter' } } , 'tags' => [ 'custom' ]
182
194
}
183
195
} ,
184
196
'/items' => {
@@ -340,24 +352,38 @@ def app
340
352
end
341
353
end
342
354
355
+ # TODO: Rendering a custom param type the way it is done here is not valid OpenAPI
356
+ # (nor I believe it is valid Swagger 2.0). We should render such a type with a JSON reference
357
+ # under components/schemas.
343
358
describe 'supports custom params types' do
344
359
subject do
345
360
get '/swagger_doc/custom.json'
346
- raise ( 'TODO: Fix' )
347
361
JSON . parse ( last_response . body )
348
362
end
349
363
350
364
specify do
351
365
expect ( subject [ 'paths' ] ) . to eq (
352
366
'/custom' => {
353
- 'get ' => {
367
+ 'post ' => {
354
368
'description' => 'this uses a custom parameter' ,
355
- 'operationId' => 'getCustom' ,
356
- 'responses' => {
357
- '200' => { 'content' => { 'application/json' => { } } ,
358
- 'description' => 'this uses a custom parameter' }
359
- } ,
360
- 'tags' => [ 'custom' ]
369
+ 'operationId' => 'postCustom' ,
370
+ 'requestBody' => {
371
+ 'content' => {
372
+ 'application/json' => { 'schema' => { 'properties' => { } , 'type' => 'object' } } ,
373
+ 'application/x-www-form-urlencoded' => {
374
+ 'schema' => {
375
+ 'properties' => {
376
+ 'custom' => {
377
+ 'description' => 'array of items' ,
378
+ 'items' => { 'type' => 'CustomType' } ,
379
+ 'type' => 'array'
380
+ }
381
+ } ,
382
+ 'type' => 'object'
383
+ }
384
+ }
385
+ }
386
+ } , 'responses' => { '201' => { 'description' => 'this uses a custom parameter' } } , 'tags' => [ 'custom' ]
361
387
}
362
388
}
363
389
)
0 commit comments