-
Notifications
You must be signed in to change notification settings - Fork 118
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
Empty arrays are omitted from query params #570
Comments
I'm also noticing that this is the last query param, then the URL ends with a dangling
|
Alternatively, we may want to go with the This would have the added advantage of being more conformant, and servers that look up the |
Can you please file a separate issue for this? Should be easy to fix hopefully. |
Please double check me on this, but from my reading of the specifications, omitting any keys for an empty array seems like the correct behavior. OpenAPI 3.1 form exploded query items: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values Delegates the rules to https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.8 Which adds the key only for items in the array. So if there are no items in the array, there are no keys in the URL. Putting So to your point: "there's no distinction between [] and nil" - yes, that's my reading of RFC6570. |
In the last 24 hours I’ve come to realize that this is both correct and also very unfortunate. Thanks for bringing receipts and actually referencing the specifications too! |
Description
For an OpenAPI route with the following
get
parameter:If one were to pass
colors: []
in the generated code, theURISerializer
from swift-openapi-runtime would completely omit the query parameter instead of passing say?colors[]=
to specify that the array is empty.Reproduction
See above
Package version(s)
Expected behavior
[]
vsnil
should be differentiated somehow.Environment
Swift 5.10
Additional information
No response
The text was updated successfully, but these errors were encountered: