Parameter defaults ignored when nested inside hash
Author: tlconnorCreated Jun 23, 2020Updated Jun 19, 2024
Labelsbug?
I'm not sure if this is the intended behavior or not, but there appears to be a problem with the :default option on params that are nested inside another param of type Hash.
For example, given this code:
params do
optional :filter, type: Hash do
optional :status, default: 'new'
end
end
get do
params
endIf I call this API, I would expect to get back:
{ "filter": { "status": "new" } }but instead it will respond with
{}I have a commit with an example failing test case. https://github.com/tlconnor/grape/commit/26beeab
Source: ruby-grape/grape