Open maticardenas opened 1 year ago
Hi, Matías! Thanks for your question! I'm not sure if this is an error. A correct way of passing an array of values using the query string is:
?array=value1&array=value2&array=value3
You can also pass a single string with comma-separated values, like:
?array=value1,value2
There's no standard way of passing arrays (it depends on the implementation/framework), but repeating the name of the variable in the query string is a commonly accepted one (the default way in several web frameworks, actually). I think this is what is reflected in the generated collection.
If you are using a single string with comma-separated values, perhaps you have to change the OpenAPI definition to reflect that. This article can give you more information about this: https://medium.com/raml-api/arrays-in-query-params-33189628fa68
Please let me know if you need more help.
Hi @davidespihernandez the main problem here is that it is not very clear that this is a list/array. Maybe would be good to add a remark on the representation (e.g. an array of strings)
Hey @petkostas, Thanks for your question.
As @davidespihernandez has mentioned, there can be multiple ways of passing an array of values
as a query string. The representation depends on the backend server's framework, hence the repetition of the variable name itself can be considered as a representation of an array of values
.
If you would like to pass the array of values
as a single string with comma-separated values, you can make use of the style
and explode
attributes of the Parameter object.
For Example:-
parameters:
- schema:
type: array
items:
type: string
example: postnl
in: query
name: carrier_code
description: selection of carriers
required: true
style: form
explode: false
You can refer to the following link for further details and examples about style
and explode
attributes. https://spec.openapis.org/oas/v3.1.0#style-values
Please let us know if you need more help.
@aman-v-singh I am not referring to the implementation. I am referring to how Postman displays them. It isn't very clear for the user (check the screenshot of @maticardenas ) when he sees the multiple keys in the Query params table of Postman.
Is there an existing issue for this?
Describe the Issue
We have the update of our public collections automated through the usage of Postman API's /import/openapi endpoint. We've noticed that one of our endpoints got a duplicated query parameter, and after doing some test we identified that this only happens when the parameter is defined as an
array
ofstring
in its OAS definition:In other paths and endpoints that we have in the same OAS where the parameter is defined as simple
string
, duplication at the collection doesn't happen.Steps To Reproduce
array
withitems
of typestring
Screenshots or Videos
Operating System
macOS
Postman Version
10.12.11
Postman Platform
Postman App
User Account Type
Signed In User
Additional Context?
No response