-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
collectionFormat should support key[]=value #442
Comments
It supports it already. Just give the parameter the name |
The ui when generated with: {
"required": false,
"collectionFormat": "multi",
"type": "array",
"items": {
"type": "string"
},
"name": "categories",
"in": "query"
} generates request that sends
What I need is
|
Right, so the generated name should be |
I can make the tool generate name categories[]: {
"required": false,
"collectionFormat": "multi",
"type": "array",
"items": {
"type": "string"
},
"name": "categories[]",
"in": "query"
} the problem is that swagger-ui then encodes [] to categories%5B%5D. Another big problem is semantics:
Problem is swagger-ui can't differentiate, because it doesn't see the differences. |
As far as the ui encoding the square brackets, just open an issue on swagger-ui. As for the difference in semantics, that's a tooling issue. We can't accommodate for every single variation a tool out there decides to use. Whether a single value, or an array of a single value, in most cases (I'm sure there are edge cases), those should mean the same thing (especially to an API consumer). Therefore, the ui doesn't need to differentiate as the meaning is pretty much the same. |
To create an issue I need to differentiate between parameters that can be either string or array via spec. Otherwise I have no ground rule for ui to differentiate. |
As long as you define the name as |
Seems like there's quite a bit of overlap in #380, closing this we can carry on there. Please add any refinements you feel may have been missed. |
Regarding joi not integrating delimeters hapijs/joi#570 and https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md not supporting key[]=value. I would like to suggest adding this so it would be easy to use swagger-ui in more platforms that predefined key[]=value for array values. Currently I am using https://github.com/z0mt3c/hapi-swaggered. Hope you guys can help. If needed I can update the code myself. It's just adding one more way of parsing and adding more tests.
The text was updated successfully, but these errors were encountered: