Chanté Gobel
Chanté Gobel

Reputation: 69

Swagger 2,0 query parameter syntax for a list or array of integers

I have been wrecking my brain reading docs and trying to successfully pass through a list or an array of integers using swagger because I am trying to test my API.

I am trying to pass through a list of teamIDs like this: (I've been trying all kinds of variations, mind you) but the values are still not pulling through when I debug

 {
"type": "array",
    "items": {
        "type": "integer",
        "enum": [
            1,
            2,
            3
        ]
   }

I am using "enum" because its a list of values I am trying to pass through.

Here is a screenshot of my swagger method as well:

enter image description here

Upvotes: 2

Views: 3582

Answers (1)

Helen
Helen

Reputation: 97991

A query parameter that is an array of integers is defined as follows:

{
  "in: query",
  "name": "teamIDs",
  "type": "array",
  "items": {
    "type": "integer"
  }
}

In your Swagger UI, enter the values for the teamIDs parameter one per line, like so:

1
2
3

Upvotes: 1

Related Questions