ruby-grape / grape-swagger-rails

Swagger UI as Rails Engine for grape-swagger gem.
MIT License
251 stars 197 forks source link

Array of object is not built properly #88

Open bekicot opened 5 years ago

bekicot commented 5 years ago

I have this definition in my API

params do
requires :daycare_attributes, type: Hash do
  requires :departments_attributes, type: Array do
    requires :name
  end
end

The UI shows image

Which is fine. But when I try it, it doesn't build the array properly. In the curl, it built something like

curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d \
'daycare_attributes[departments_attributes]%5Bname%5D=Math&daycare_attributes[departments_attributes]%5Bname%5D=Phsyics' \
'http://localhost:3000/api/'

To pass the grape parameter validation. It must be

curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d \
'daycare_attributes[departments_attributes][][name]=Math&daycare_attributes[departments_attributes][][name]=Phsyics'\
 'http://localhost:3000/api/'

Both curl and UI xhr failed to pass the validation.