@@ -61,7 +61,7 @@ class SimpleMountedApi < Grape::API
6161 'custom' => { type : CustomType , description : 'array of items' , is_array : true }
6262 }
6363
64- get '/custom' do
64+ post '/custom' do
6565 { }
6666 end
6767 end
@@ -171,14 +171,26 @@ def app
171171 }
172172 } ,
173173 '/custom' => {
174- 'get ' => {
174+ 'post ' => {
175175 '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' ]
182194 }
183195 } ,
184196 '/items' => {
@@ -340,24 +352,38 @@ def app
340352 end
341353 end
342354
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.
343358 describe 'supports custom params types' do
344359 subject do
345360 get '/swagger_doc/custom.json'
346- raise ( 'TODO: Fix' )
347361 JSON . parse ( last_response . body )
348362 end
349363
350364 specify do
351365 expect ( subject [ 'paths' ] ) . to eq (
352366 '/custom' => {
353- 'get ' => {
367+ 'post ' => {
354368 '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' ]
361387 }
362388 }
363389 )
0 commit comments