question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Use JSON in @Query() instead of url encode

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nartccommented, Dec 10, 2019

Looks like that is the case. However, content isn’t supported until SwaggerUI 3.23.7+ as stated here in OpenAPI Documentations image

I just double checked swagger-ui-express and it’s running off of swagger-ui: 3.18 https://github.com/scottie1984/swagger-ui-express/blob/master/package.json#L49

I’d suggest keeping track of OR raise another issue asking swagger-ui-express to support swagger-ui: 3.23.7+ then we can consider adding this as a feature to nestjs/swagger

0reactions
lock[bot]commented, Apr 25, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found