ruby-grape / ruby-grape/grape-swagger
Bug report: omitted array parameters with `array_use_braces: true`
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 479
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 6
Description
When array_use_braces is set to true, array parameters are omitted when they are body parameters but don't explicitly specify documentation: { param_type: "body" }.
Example:
# with add_swagger_documentation(array_use_braces: true)
params do
requires :param1, type: Array[String]
requires :param2, type: Array[Integer], documentation: { param_type: "body" }
end
post :foo do
{ declared_params: declared(params)
end
The spec will look like:
"postFoo": {
"required": ["param2"],
"type": "object",
"properties": {
"param2": {
"type": "array",
"items": { "type": "integer", "format": "int32" }
}
}
}
It is particularly annoying if one wants to share some params between GET and POST/PUT/PATCH endpoints and rely on the implicit behavior to have the params be query params or body params as appropriate.
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
Reproduce the example using add_swagger_documentation(array_use_braces: true) with the shared params and compare the generated specification. Trace how the array parameters are classified for GET versus POST/PUT/PATCH body parameters; done means the implicitly body-scoped param1 is included while the explicitly documented param2 remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100