[Feature Request] Use JSON in @Query() instead of url encode
See original GitHub issueI’m submitting a…
[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
@Get("endpoint")
async endpoint(@Query(): request: RequestDTO): Promise<ResponseDTO> {
// ...
}
The RequestDTO
type is extracted to url encoded fields, losing its types.
Expected behavior
Just like POST’s body, the querystring is JSON. Swagger UI should provide a JSON input UI instead of simple typeless form inputs.
What is the motivation / use case for changing the behavior?
Encode query paramaters with JSON can preverse their types, which is useful for input validating.
This feature should be disabled by default and a per-method decorator and a global option provided to enable this.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Parse JSON-encoded query strings in FastAPI
FastAPI parses your request and maps it to controller parameters. Can I turn complex parameters in the query string into Pydantic models?
Read more >How to escape a JSON string to have it in a URL?
Show activity on this post. encodeURIComponent(JSON.stringify(object_to_be_serialised)) ... Rather than URL-encoding the data, you can base64-encode it.
Read more >encodeURIComponent() - JavaScript - MDN Web Docs
Compared to encodeURI() , this function encodes more characters, ... A string to be encoded as a URI component (a path, query string, ......
Read more >The ENCODE REST API
The resource you GET, using that URL, will be in JSON format. ... Sending a GET request is accomplished here by using the...
Read more >Use query parameters to customize responses - Microsoft Graph
For example, instead of $filter , you can use filter . On the v1 endpoint, the $ prefix is optional for only a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like that is the case. However,
content
isn’t supported untilSwaggerUI 3.23.7+
as stated here in OpenAPI DocumentationsI just double checked
swagger-ui-express
and it’s running off ofswagger-ui: 3.18
https://github.com/scottie1984/swagger-ui-express/blob/master/package.json#L49I’d suggest keeping track of OR raise another issue asking
swagger-ui-express
to supportswagger-ui: 3.23.7+
then we can consider adding this as a feature tonestjs/swagger
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.