-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Params: optional arrays within hashes/JSON objects broken #2001
base: master
Are you sure you want to change the base?
Conversation
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 🚫 danger |
5d0537f
to
034ed90
Compare
Makes sense, thanks for the test! |
@dleavitt now that we have a test (thanks), try fixing it? |
post '/nesty', { data: { } } | ||
expect(last_response.status).to eq 201 | ||
# {"data"=>{"json"=>{"name"=>nil}}} | ||
expect(JSON.parse(last_response.body)['data']['json']).not_to be_a Hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess here we should expect the hash. @dleavitt could you verify this test?
I ran these tests and only params with nested JSON's seem to be broken. And it is fixable by calling Also, looking at the rest of the specs from |
Feel free to close if you're cleaning house! |
See failing tests below for more specifics.
To reproduce
In a params block, define an array param within a Hash or JSON param:
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.