Add support for query param array format
There is no standard for handling arrays as query parameters. We should be able to add a format structure to let the API server specify what it expects, and have swagger-js + codegen produce the correct structure.
@webron Okey, wordnik/swagger-ui#661
@kiaplayer - thank you for taking the time.
@webron I think we're missing two collectionFormat values in the spec. Many frameworks want this:
a=1&a=2&a=3
to represent a list a with values (1,2,3). This includes jaxrs, and you're describing multi in this ticket which isn't actually in the spec right now (that I see).
Similarly, many frameworks want the brackets in the name like in this initial issue, and it seems like this might be a named format, like brackets or something. Would make life much easier in the js library, since we don't need to handle special characters in the parameter name (the brackets will be encoded by default):
https://github.com/wordnik/swagger-js/blob/develop_2.0/src/main/javascript/swagger.js#L624
multi is described in the spec and the schema - https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#parameterCollectionFormat with a few restrictions (it's only relevant in query and formData params).
I think you need to handle special characters in the name one way or another. What if someone decides to name their parameter api-key? Or have some accented letters in the parameter name? Wouldn't all those cause issues as well? I can add it, of course, it just feels like we're dealing with an edge case rather than the problem as a whole.
Hi! I've also had recently a problem representing this: productID1=1&productID2=2&... I'm rewriting a hand-written API spec. as swagger.yaml
@packpaul that URI syntax can't be represented in OpenAPI (neither in version 2.0 nor what is currently proprosed in 3.0, as far as I understand).
I didn't know it. So here's a proposal to implement it in the following version.
Please open a new issue (with a more detailed proposal how you imagine it to be represented). Commenting on closed issues doesn't help.
the brackets will be encoded by default
Isn't this the bug? Encoding characters that need not be encoded is just... wrong is it not?
Brackets in fields names are encoded anyway
Isn't this the bug? Encoding characters that need not be encoded is just... wrong is it not?
Actually, the encoded brackets work (at least with PHP), so ?array[]=1&array[]=2 is the same as ?array%5B%5D=1&array%5B%5D=2