ruby-grape / ruby-grape/grape-swagger
Include array responses in http_codes?
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 479
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 6
Description
Hi everyone,
I found the is_array in the desc parameter for an API endpoint to specify an array as response. But I didn't find how to specify that in the http_codes part, something like:
desc "List All Delivery",
is_array: true,
entity: ::Delivery::Entity,
http_codes: [
[200, 'OK', ::Delivery::Entity],
[401, 'Unauthorized', API::Entities::Error],
[403, 'Forbidden', API::Entities::Error]
]
get do
present(paginate(::Delivery.all),
with: ::Delivery::Entity)
end
The generated Swagger documentation is my code makes you think the 200 response will give you a Hash but it won't, it's an array. Is there a way to do that?
Thanks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the desc declaration and its is_array and http_codes options shown in the issue, then trace how the generated Swagger/OpenAPI response schema is formed. Done means the 200 response is documented as an array while the 401 and 403 responses remain error entities; the issue names no file or test path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, ruby
- Domain
- api, documentation
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100