Skip to content

Commit

Permalink
Fix spec
Browse files Browse the repository at this point in the history
  • Loading branch information
blake authored and numbata committed Jul 12, 2024
1 parent 5d6bb3a commit 9713a2b
Showing 1 changed file with 42 additions and 16 deletions.
58 changes: 42 additions & 16 deletions spec/openapi_3/simple_mounted_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SimpleMountedApi < Grape::API
'custom' => { type: CustomType, description: 'array of items', is_array: true }
}

get '/custom' do
post '/custom' do
{}
end
end
Expand Down Expand Up @@ -171,14 +171,26 @@ def app
}
},
'/custom' => {
'get' => {
'post' => {
'description' => 'this uses a custom parameter',
'operationId' => 'getCustom',
'responses' => { '200' => {
'content' => { 'application/json' => {} },
'description' => 'this uses a custom parameter'
} },
'tags' => ['custom']
'operationId' => 'postCustom',
'requestBody' => {
'content' => {
'application/json' => { 'schema' => { 'properties' => {}, 'type' => 'object' } },
'application/x-www-form-urlencoded' => {
'schema' => {
'properties' => {
'custom' => {
'description' => 'array of items',
'items' => { 'type' => 'CustomType' },
'type' => 'array'
}
},
'type' => 'object'
}
}
}
}, 'responses' => { '201' => { 'description' => 'this uses a custom parameter' } }, 'tags' => ['custom']
}
},
'/items' => {
Expand Down Expand Up @@ -340,24 +352,38 @@ def app
end
end

# TODO: Rendering a custom param type the way it is done here is not valid OpenAPI
# (nor I believe it is valid Swagger 2.0). We should render such a type with a JSON reference
# under components/schemas.
describe 'supports custom params types' do
subject do
get '/swagger_doc/custom.json'
raise('TODO: Fix')
JSON.parse(last_response.body)
end

specify do
expect(subject['paths']).to eq(
'/custom' => {
'get' => {
'post' => {
'description' => 'this uses a custom parameter',
'operationId' => 'getCustom',
'responses' => {
'200' => { 'content' => { 'application/json' => {} },
'description' => 'this uses a custom parameter' }
},
'tags' => ['custom']
'operationId' => 'postCustom',
'requestBody' => {
'content' => {
'application/json' => { 'schema' => { 'properties' => {}, 'type' => 'object' } },
'application/x-www-form-urlencoded' => {
'schema' => {
'properties' => {
'custom' => {
'description' => 'array of items',
'items' => { 'type' => 'CustomType' },
'type' => 'array'
}
},
'type' => 'object'
}
}
}
}, 'responses' => { '201' => { 'description' => 'this uses a custom parameter' } }, 'tags' => ['custom']
}
}
)
Expand Down

0 comments on commit 9713a2b

Please sign in to comment.