2

I am trying to send multiple values (an array) (refer to on line 93 in spec ->... name: recipients[] ...)

The problem I am facing is the Swagger-ui call the endpoints as below:

Actual

recipients[]=value1%2Cvalue2

Expected

recipients[]=value1&recipients[]=value2

The %2C means , (comma).

Below are the required details swagger-ui version 2.1.1 Below is the link for content of the swagger spec file reproducing the issue: http://pastebin.com/V3ZuCjVz

1 Answer 1

5

It looks like the way to specify this is to add collectionFormat: multi

- name: recipients[]
  in: formData
  description: Email addresses for recipients (multiple values allowed).
  required: true
  type: array
  collectionFormat: multi
  items:
      type: string

Possible values from http://swagger.io/specification/ are:

  • csv - comma separated values foo,bar.
  • ssv - space separated values foo bar.
  • tsv - tab separated values foo\tbar.
  • pipes - pipe separated values foo|bar.
  • multi - corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in "query" or "formData".
Sign up to request clarification or add additional context in comments.

2 Comments

I tried this, but still not working :(. here is the swagger spec after the changes: pastebin.com/t47xjFQw (refer to recipients)
I have reported this issue with swagger-ui (also swagger-js) project. The team is responsive and they are working on it. These are the urls: github.com/swagger-api/swagger-ui/issues/2067 github.com/swagger-api/swagger-js/issues/749

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.