-
Notifications
You must be signed in to change notification settings - Fork 9k
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
How to declare parameter values mixing possibilities #1669
Comments
I think I've found the answer by myself... The code above implicitely says that one and only one value can be provided for each parameter. In order to allow multiple values for a single parameter the $ref must be nested within an array: parameters:
- name: breed
in: query
schema:
type: array
items:
$ref: "#/components/schemas/breeds"
style: form
explode: true
required: false It is worth to note that Swagger UI correctly deals with these situation, presenting a dropdown in a case such as the one in my original example (thus allowing to select only a single value), while switching to a multiple-choice listbox when putting the possible values within an array. Am I correct? One last thing: if I'm not wrong, this basically means that it makes no sense to put "style" and "explode" keywords without putting also the "array" one, because in this case no serialization can be applied... Thank you again! |
I believe your main point is correct (though the definition of the For a full breakdown of the effect of these fields, see here. Hope this answers your query (if so, feel free to close the issue). |
Hi @MikeRalphson. Thank you for your help. I must confess that I'm still a bit confused (perhaps it's my fault....). In my original example, at te beginning of this thread, I specified But, as far as I understand, without "nesting" everything under If you pass more than one value to the parameter (e.g., by using some sort of separator) this would probably result in having all the values concatenated and then passed as a single one. Obviously (well... at least I think so...), any kind of Am I correct? Thank you again, Alberto. |
|
This issue has been labeled with |
Hi.
I'm having difficulties while trying to express in a Swagger definition a relatively simple concept.
Let's assume we have a parameter for a GET which takes acceptable values from an array.
How could I clarify within my spec that such values can be mixed (that is, more than one value can be used in a single request) or, at the opposite, that only one of them is accepted in a single request?
Is explicitely declaring the serialization method with "style" and "explode" tags enough to let developers understand thate more than one value can be used in a single request?
At the opposite, without putting in my spec these two tags can I assume that it will be clear enough to devs that they must pass one (and only one) of the possible values?
Here it follows an example built upon my spec.
Thank you for any help!
The text was updated successfully, but these errors were encountered: