Closed
Description
When an endpoint is generated in the swagger doc the description
field of the response model is set incorrectly:
@definitions[response_model][:description] = description_object(route)
The description_object(route) method returns the description
of the route, which can be really long and is different for each route!
So if you have an endpoint, say, getKittens:
desc 'Get all kittens!', {
nickname: 'getKittens',
success: Entities::Kitten
failure: [[401, 'KittenBitesError', Entities::BadKitten]]
}
get '/kittens' do
puts "meow"
end
Grape Swagger will define the new models Kitten and also BadKitten and will apply the same description in the the definition. Swagger generated doc:
definitions:
kitten:
type: object
properties:
fluffy:
type: boolean
description: Indicates if the kitten is fluffy or not!
required:
- fluffy
description: Get all kittens!
If you use the KittenEntity
as a response somewhere else, then the model definition description will get overwritten once more with the description of the route.
Since the description of the route is in no way useful for the model description I suggest we simply replace it with a generic description:
@definitions[response_model][:description] = "A #{response_model} model"
Metadata
Metadata
Assignees
Labels
No labels