问题
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:
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".
来源:https://stackoverflow.com/questions/36329771/swagger-ui-not-sending-array-correctly