How to change query parameter name in swagger?


How to change query parameter name in swagger?



I am trying to get this url:



https://search.me/Search/api/search?map=%7B%22query%22:%22CSCI+250%22,%22rows%22:500,%22term%22:%222181%22,%22career%22:%22%22,%7D


https://search.me/Search/api/search?map=%7B%22query%22:%22CSCI+250%22,%22rows%22:500,%22term%22:%222181%22,%22career%22:%22%22,%7D



without converting special characters to HEX to URL would be:



https://search.me/Search/api/search?map={query:CSCI-250,rows:500,term:2181,career:}


https://search.me/Search/api/search?map={query:CSCI-250,rows:500,term:2181,career:}



I know it is not possible to serialize special characters as hex in openapi 3.0.0, so I am fine with the full JSON in the query parameter.



Where the parameter is a JSON -> URI
The JSON is:


{
map: {
"query": "CSCI 250",
"rows": 500,
"term": 2181,
"career": ""
}
}



but swagger instead renders:



https://search.me/search/api/search?query=CSCI-250&rows=500&term=2181&career=


https://search.me/search/api/search?query=CSCI-250&rows=500&term=2181&career=



As you can see, special characters are then converted into HEX.



Below is my path. What exactly am I doing wrong?


paths:
/search:
get:
summary: Search
parameters:
- in: query
name: map
description: JSON for lookup
required: true
schema:
$ref: '#/components/schemas/QueryParams'
responses:
200:
description: Course search response
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/QueryResults'
400:
description: Bad request





Is the expected example .../map?=CSCI-250 correct? It has = directly after ? so the first parameter name seems to be missing.
– Helen
Jul 2 at 14:01


.../map?=CSCI-250


=


?





I added the correct URL that I need. @Helen
– Pants
Jul 2 at 14:17





I don't mind not converting to hex as I documented this, I just want the correct parameter name to be displayed. Should be map not query
– Pants
Jul 2 at 14:20


map


query





Possible duplicate of Defining an API with swagger: GET call that uses JSON in parameters
– Helen
Jul 2 at 14:40





My answer there is for OpenAPI 3.0.
– Helen
Jul 2 at 14:59









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages