Skip to content

Question about body parameters of type Array #306

Closed
@rkrage

Description

@rkrage

So here I have the definition of my endpoint, the format of the payload being sent, and the documentation generated by grape-swagger: https://gist.github.com/rkrage/b0ddd66b395cd9aa741d

Sending the described payload populates the parameters just fine in grape, but the documentation doesn't look quite right in the swagger UI.

swagger UI

(Also for some reason the name of the param is "body" instead of "data")

After digging a bit, I think this is just a limitation of swagger and it even looks like grape-swagger sort of hacks multiple body params into form params to make the UI look pretty, but I guess it can't do that for params with type Array.

Is my only option to define one top level body param with the fields nested below?

params do
  optional :root, type: Hash, desc: 'Nested options'
end
{
   "root":{
      "details":"this is my payload",
      "data":[
         {
            "key1":"value1"
         },
         {
            "key2":"value2"
         }
      ]
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions