grape
grape copied to clipboard
Params: optional arrays within hashes/JSON objects broken
See failing tests below for more specifics.
To reproduce In a params block, define an array param within a Hash or JSON param:
params do
optional :data, type: Hash do
optional :array, type: Array do
optional :name, type: String
end
end
end
When the request body looks like this: { data: {} }
I'd expect that calling declared(params) within the route would return something like this:
{ data: { array: [] } }
or maybe this:
{ data: {} }
What's actually returned is this:
{ data: { array: { name: nil } } }
A hash rather than an array.
| 1 Warning | |
|---|---|
| :warning: | Unless you’re refactoring existing code, please update CHANGELOG.md. |
| 1 Message | |
|---|---|
| :book: | We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests! |
Here's an example of a CHANGELOG.md entry:
* [#2001](https://github.com/ruby-grape/grape/pull/2001): Params: optional arrays within hashes/json objects broken - [@dleavitt](https://github.com/dleavitt).
Generated by :no_entry_sign: danger
Makes sense, thanks for the test!
@dleavitt now that we have a test (thanks), try fixing it?