swagger-ui: Swagger UI doesn't seem to support Arrays yet?

Hey there,

Please excuse my relative ignorance, I’m using Swagger within the context of a rails app and I’m not particularly up to date with where swagger’s UI is in comparison with swagger’s spec. I wanted to ask, has the UI implemented the Array type? I want to be able to define an API with parameters that would resolve to this in the API:

foo[]=1&foo[]=2&foo[]=3

In grape-swagger-rails I’m able to define a parameter as such:

requires :foo, type: Array[Integer], desc: 'An Array of Foos'

grape-swagger-rails (I think it’s that gem which does this) renders the following JSON spec:

Imgur

And Swagger UI renders the output like this:

Imgur

When it queries the API, it generates the following url:

http://localhost/example?foo=1

Which of course works, but isn’t helpful for allowing people to test.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 24 (11 by maintainers)

Most upvoted comments

That’s not the right definition for an array. You need to end up with something that looks like:

"type": "array",
"items": {
  "type": "integer"
}

I have just ran into this issue on master. Is it possibly a regression?

Swagger UI takes whatever I put into the text area and url encodes it into a single parameter. It should be multiple parameters with the same name. See screenshots below.

image

image

Hi @fehguy, thanks for your answer, but I know the standards. For example:

{
    "name": "devices",
    "in": "formData",
    "type": "array",
    "items": {
        "type": "integer"
    },
    "collectionFormat": "multi"
}

I should be able in UI to put in devices fileld values: “1&2&3” or “1,2,3” and the post parameters should look like: devices: 1 devices: 2 devices: 3 but currently it looks like “devices: 1,2,3”