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.

Not able to parse @QueryParams()

See original GitHub issue
class SortOrder {
  [index: string]: 'ASC' | 'DESC'
}

class Query {
  @IsNumber()
  readonly offset: number = 0;

  @IsNumber()
  readonly limit: number = 10;

  @ValidateNested()
  readonly order: SortOrder;
}

class Controller {
  getAll(@QueryParams() query: Query) {
    
  }
}

This example creates one field called query and displays it as json field.

Expected behavior is to have 3 query parameters: offset, limit and order. Order parameter should be of deepObject style.

Example query string:

?limit=10&offset=0&order[firstName]=DESC&order[lastName]=ASC

More info https://swagger.io/docs/specification/serialization/

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gstamaccommented, Nov 26, 2020

I regenerate the parameters after the spec is generated. In short go through the whole spec and if I find a “query” parameter that has “$ref” set I lookup the schema and replace the parameter.

1reaction
gstamaccommented, Apr 15, 2019

This should actually be the default behavior. QueryParams should be expanded because it represents the whole query object (or at least part of it) not just one query parameter. I’ll take a look and maybe create a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to parse query parameters with # url - Stack Overflow
getQuery() gives null. Any method to parse it with explicitly removing # from url. java · url · urlencode.
Read more >
urllib.parse — Parse URLs into components — Python 3.11.1 ...
Source code: Lib/urllib/parse.py This module defines a standard interface to break Uniform Resource Locator (URL) strings up in components (addressing ...
Read more >
parse_url - Manual - PHP
This function parses a URL and returns an associative array containing any of the various components of the URL that are present.
Read more >
Query parameters - Dreamdata | Docs
You can use URL query parameters in your links to pass User ID, ... be because of privacy reasons are not having the...
Read more >
How to migrate from querystring to URLSearchParams in ...
Is used by querystring.parse(). ... “Unlike querystring module, duplicate keys in the form of array values are not allowed.
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