-
Notifications
You must be signed in to change notification settings - Fork 9.1k
v3.2: Add in: "querystring"
parameter location treating the entire query string as one chunk of content
#4590
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
base: v3.2-dev
Are you sure you want to change the base?
Conversation
This allows treating the entire query string as a single parameter, which for `application/x-www-form-urlencoded` results in it being handled exactly as request bodies of that media type are handled. Only one `in: "querystring"` is allowed per operation, and if it is present, no `in: "query"` parameters are allowed. The `content` field MUST be used for `in: "querystring"`, as the `style` and related fields are handled in the Encoding Object. This also includes a recommendation that implementors design media types for complex query string formats such as those defined by various frameworks, and register a procedure for supporting them in our media type registry. This is intended to address a slow but steady trickle of requests to support various complex and often contradictory query string formats.
in: "querystring"
parameter location treating the entire query string as one chunk of contentin: "querystring"
parameter location treating the entire query string as one chunk of content
@handrews : I just want to confirm my understanding—so that I can plan for related tooling: when we have a parameter which has a |
@davebelais replace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I LOVE this addition!
Co-authored-by: Lorna Jane Mitchell <github@lornajane.net>
Replace "no defined mapping" with "no registered mapping" and link to the section about the registry.
This latest commit replaces "no defined mapping" with "no registered mapping" (linking to the section on the registry) in the JSONPath example. It also adds a serialized form to the JSON |
@handrews Hi. When I follow the click path (under the overall media type reg section) with respect to the media registry, I end up with this URL: https://spec.openapis.org/registry/media-type/ which is broken (404). |
@miqui yeah we still need to put the registry up. It will be published along with 3.2 and 3.1.2, so it's expected to be broken for now. |
Also worth noting -- this solves the "how do I indicate a relationship or dependency between query parameters" usecase -- as this allows for declaring all query parameters as being decoded to a json object, to let us use more complicated json schema constructs e.g. minProperties, if/then/else, anyOf etc. Note -- We already could do that today, if you squint at the specification the right way, by specifying the right combination of style, explode, and schema/type, but it's not explicitly spelled out in the spec and probably a lot of implementations don't support that right now. This new mechanism makes the implementation much more explicit, and it is also more adaptable to other serialization styles than just application/x-www-form-urlencoded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, questions and spelling fixes.
src/oas.md
Outdated
Two avenues are available for supporting such formats with `in: "querystring"`: | ||
|
||
* Use `content` and `text/plain` with a schema of `type: "string"` and define the format outside of OpenAPI. While this requires more work to document and construct or parse the format, which is seen as a plain string from the OpenAPI perspective, it provides the easiest flexible option | ||
* Define a media type (which need not necessarily be [IANA-registered](https://www.rfc-editor.org/rfc/rfc6838.html)) and submit a registration for how it can be supported (using `in: "querystring"` and the `content` field) to the OpenAPI Initiative's [Media Type Registry](#media-type-registry). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implies that submitting an entry to the Media Type Registry is required. It of course is not; an implementation could invent its own media type and only support it locally. This would not be interoperable outside of the scope of where the media type is defined, but I could easily see an application or company doing this for "internal" interfaces.
Can we modify this to simply recommend that new media types be submitted to the registry, to facilitate interoperability?
src/oas.md
Outdated
example: { | ||
"numbers": [1, 2], | ||
"flag": null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think this should more properly be:
example: '{"numbers": [1, 2], "flag": null }'
..as the actual content of the querystring value is a literal json string, not a json object.
Co-authored-by: Karen Etheridge <github@froods.org>
It is not necessary to register a media type to use it with the `content` field.
@karenetheridge great catches here! I have updated accordingly- see if this language about the registry works for you. I am happy to try again if it doesn't quite capture what you have in mind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@lornajane @miqui can you re-approve after these fixes of things that @karenetheridge found? |
@karenetheridge now that I am thinking more about this, I think the change to I'm going to change that one part back. There's a lot of additional debate around examples right now. so we may need to do a follow-up. I'd like to not hold this up on our example confusion if at all possible, as that applies to many things, and if we need to fix it, we can fix it here along with everywhere else if this PR is already merged. |
This is at the Media Type Object level, and JSON examples are to be written as inline JSON/YAML. If we were at the Parameter Object level, we would use the URI percent-encoded string form, but the example field is not allowed with the content field.
NOTE: This change was tentativley approved for 3.2 a long time ago, then punted to 3.3 when we thought we'd need to defer larger data modeling changes to that release. However, several things have changed that makes this suitable for 3.2 now:
encoding
in all Media Type Objects #4559 and v3.2: Support ordered multipart including streaming #4589. We should really include all of the "use the Encoding Object in more places" changes in one release!in: querystring
to usingcontent
avoids all of the confusing problems of how to deal with the Parameter Object'sstyle
/explode
/etc. in an environment where they do not make sense (and duplicate the fields in the Encoding Object)deepObject
but now can be done while also usingstyle
/explode
for individual parameters)$ref
s comes pretty close)in: querystring, content: {text/plain: {...}
:This allows treating the entire query string as a single parameter, which for
application/x-www-form-urlencoded
results in it being handled exactly as request bodies of that media type are handled.Only one
in: "querystring"
is allowed per operation, and if it is present, noin: "query"
parameters are allowed.The
content
field MUST be used forin: "querystring"
, as thestyle
and related fields are handled in the Encoding Object.This also includes a recommendation that implementors design media types for complex query string formats such as those defined by various frameworks, and register a procedure for supporting them in our media type registry. This is intended to address a slow but steady trickle of requests to support various complex and often contradictory query string formats.