Parsing of Array Query Parameters for REST Applications and OpenAPI Specification #3491
Unanswered
Mathdrquinn
asked this question in
Q&A
Replies: 1 comment 5 replies
-
To make the problem slightly more complex, in OpenAPI 3.X nested query parameters are not supported. I'm wondering if the best approach is to flatten the query syntax into many options. Something like: {
"//": "rest of spec",
"parameters": [
{
"in": "query",
"name": "$sort[id]",
"schema": { "type": "integer", "minumum": -1, "maximum": 1 }
},
{
"description": "Number of results to skip",
"in": "query",
"name": "$sort[text]",
"schema": { "type": "integer", "minumum": -1, "maximum": 1 }
},
{
"description": "Number of results to skip",
"in": "query",
"name": "$sort[created]",
"schema": { "type": "integer", "minumum": -1, "maximum": 1 }
}
] |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm curious how the community handles documenting and consuming array query parameters.
The documentation is very clear on approach for leveraging, for example,
$select
within an application:I find the translation to REST query parameters confusing. There is an extra set of square bracket required:
GET /messages?$select[]=text&$select[]=userId
.The syntax, according to OpenAPI, seems to hint at an object query parameter in the
deepObject
style, while the docs seem to align with astyle: form
,explode: true
format.The helpful feathers-swagger package generates a swagger UI that similarly doesn't understand how to parse and handle array query syntax. The UI generates that same query as
GET /messages?$select=text&$select=userId
. This is valid, and returns results, but when requesting a single$select
value, the query validators throw, saying they require an array.tldr; How do you document query parameters that take arrays in a way that is OpenAPI 3.X compliant and aligns with Feather's documentation?
This framework has been a ton of fun to use and learn. Learning how you all navigate this finer detail could really help my projects easily integrate into the the vast tooling surrounding OpenAPI specifications.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions