-
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
Support for arbitrary query strings #1502
Comments
Hmm.... is there (or could there be) a media type for RQL query strings? Technically, the OpenAPI could offer an (interestingly, this would also allow expressing relationships among query parameters as you could use (also, I can't tell if #1054 is similar to this or not) |
As @handrews mentioned, you probably need to use the You can find a similar example for SPARQL at https://github.com/OAI/Gluecon-Workshop/blob/master/Different/parameters.md#complex-parameters-in-v3 In your case, you can try something like this: parameters:
- name: complexQuery
in: query
content:
application/rdf:
schema:
??? # type: string? type: object?
example: select(title,author)>(published,2000-06-30T12:20:08Z)&sort(published)
|
Thanks for the replies! I tried the If there's a way to prevent it from adding |
@pofallon yeah that is why I was thinking we'd need a new "in" value. So (troll mode: or, just fully support RFC 6570 :-) |
@pofallon assuming setting the name of the parameter to |
That's a good suggestion! Unfortunately it appears that with either an empty name, or no name defined at all, it omits the parameter altogether. |
I knew we were going to get bitten by something like this sooner or later. As far as I know there is no official way to do this. I suspect the best way to allow this to happen would be to allow the |
Would it be reasonable to restrict the query string to a single parameter when using the It would be interesting if we could find any examples of multiple values in a free-form string that are not following an externally-defined syntax.
My intuitive guess would be that when using |
@handrews Yeah, it would work to say style=simple can only be used in the query if it is the only query parameter.... but yuck. How many more of these ugly exceptions are we going to end up with? Makes me think the old adage is appropriate: URI templates are an icky solution that are just a little less icky than all the other solutions. |
Another usecase for this kind of scenario is Deployd's advanced queries. They end up with JSON object that takes whole query string. It could be defined in OAPI as plain string, but we would lose power of deep validation. The first @handrews's comment with |
According to From the table of examples, since I want "in: query", I can choose style from form,space delim, pipedelim or deep object. If I now use an array of size 1, and spaceDelimited, and explode=false, I should be getting the value without the variable name or the equals sign. However, https://editor.swagger.io/ still adds the "=". According to the messages above, it looks like the table in https://swagger.io/specification/#parameterContent is wrong in various places, and the parameter name is always included. The issue is that |
I would like to see this feature as well.. RAML handles it using regex, which also brings other valuable capabilities for early "rpc on http" apis. Swagger/OAS can adopt the same technique as RAML; using regex across field keys. Currently, Swagger/OAS applies regex is to field values, it should be a short hop for keys. |
This would also be useful for JSONAPI exposed through OpenAPI. What I'd like to be able to do, similar to @RubenGarcia's idea, is some way to allow the user to add multiples, but instead of just specifying the right hand side, specify the left too if that makes sense? Just illustrive - something like this:
That would allow adding multiple params of the form We can enumerate these server side for basic types, but we also have complex nested objects, and operations, such as |
@keyz182 your scenario can be described by using a - in: query
name: filter
required: false
schema:
type: object
additionalProperties: true
example:
foo: bar
inputs.datetime.gte: 242839744
style: deepObject
# The example translates to:
# ?filter[foo]=bar&filter[inputs.datetime.gte]=242839744 |
@hkosova Oh wow, that's perfect! Looks like I need to do some more RTFM :) |
This issue has a use case of an almost-but-not-quite |
As noted in a comment there, I think implementing this would also allow more experimentation with This could also be explicitly called out as an extension point so that tools can provide a hook for 3rd-party support, rather than adding an open-ended mandatory tooling requirement. |
@OAI/tsc review request: Let's approve this for 3.2, and I can write a PR to add Parity with form-urlencoded request bodiesin: queryString
content:
application/x-www-form-urlencoded: {...} This provides exact parity with how
Ability to use (and experiment with) arbitrary query string formatsThis is the original motivation for this issue. This would also allow us to recommend that people who want new/complex query serializations define a media type and a way to model them in schemas as an extension, particularly if we implement #3771 (Registry of media type modeling approaches). This could arguably allow us to close (by deferring to extensions) issues including:
All of these request new serialization approaches based on either existing formats that we can't easily describe (OData) or on a variety of other formats used elsewhere, or just directly requested for one reason or another. It's unlikely that we'd deal with any of these because this area is complex enough as it is, but given users full control over the query string gives them a way to solve it themselves. |
Discussed in this week's TDC meeting and agreed that this idea has lots of merit. We requested @handrews to work this into a formal proposal to target 3.2 |
Hello! I'm trying to use the OpenAPI 3.0 spec to document an API that supports a subset of the Resource Query Language (RQL). However, because this query string format doesn't adhere to the typical
name=value
parameter structure, I'm struggling to express it in OpenAPI.For example, a valid query string might be:
http://localhost:5000/books?select(title,author)>(published,2000-06-30T12:20:08Z)&sort(published)
.I wouldn't expect OpenAPI to understand RQL, but if there were a way to specify that an endpoint may have a query string, and that the query string contents are beyond the scope of OpenAPI, that would suffice. (I'm really thinking from the Swagger UI perspective -- so a user wanting to try the API can type in the entire RQL query string themselves.)
If anyone has any thoughts on other ways this can be accomplished with the existing 3.0 specification, that would be great too!
Thanks,
Paul
The text was updated successfully, but these errors were encountered: