Comments (9)
I'm also having the same issue.
Would be nice getting this addressed.
from nestia.
The main issue is that if somebody is already using its own querystring parser that works in nestjs, it stops working once nestia is installed since you are not using already parsed query value that Express/Fastify framework already handled.
We have spend few hours debugging why we are receiving completely different values with TypedQuery which should happen
from nestia.
I will study how native nestjs (platform of both express and fastify), and will determine how.
from nestia.
Your suggestion is a typical anti pattern that violating standard.
If you write a query string "person.address.id=2
", it means obj["person.address.id"] = 2
in the query string spec.
Also, URL path has length limit in most browsers (about 1,023), and nested query is much dangerous than non-nested.
from nestia.
Instead, I recommend to use request body of POST/PATCH/PUT/DELETE methods.
The request body does not have any length and depth limit.
In my case, I prefer PATCH
method when replacing GET
method endpoint for the same reason with you.
from nestia.
In that case, it would better to use @Query()
of original NestJS.
Also, in that case, how serialize the query string in the frontend application?
I need to update the SDK generator only for @Query()
decorator case.
from nestia.
PHP and similar languages are supporting nested associative arrays natively when parsing querystring therefore quite a lot of people used nested objects - NodeJS ecosystem offloaded support to 3rd party libraries like qs
.
Origins of our problem started few weeks ago when swagger client library was updated and it started generating querystring using JSON.stringify
for arrays instead of comma separated values and backend started throwing exceptions for those queries - therefore we started using qs
library for parsing querystring but it was ignored by nestia.
swagger-js v3.26.6
Example of QS stringify
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
// 'a[0]=b&a[1]=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
// 'a[]=b&a[]=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
// 'a=b&a=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'comma' })
// 'a=b,c'
qs.stringify({ a: { b: { c: 'd', e: 'f' } } });
// 'a[b][c]=d&a[b][e]=f'
If it helps i might have a look and create a merge request
from nestia.
Oh my god, looking at the format option, it seems terrible and why could not be standard.
Have you to use it? It seems not easy to support from SDK generator.
from nestia.
We have been using deep nested object serialization for past 20 years, since my backend origins were PHP.
Nonetheless swagger does offer deepObject serialization type and it is the only way to make it generic and universal enough so every backend can parse it
There is an option native to expressJS for parsing nested objects
const app = express();
app.set('query parser', 'extended');
from nestia.
Related Issues (20)
- Nestia swagger generates incorrect schema when using EncryptedRoute with @nestjs/cache-manager HOT 2
- Question: How to improve unit / E2E test speed HOT 2
- Nestia v2 -> v3 Migration HOT 1
- Nestjs fastify use NestInterceptor auto stringify HOT 2
- Typed Route with assertEquals HOT 4
- `https://nestia.io/docs/sdk/sdk/` is broken
- Generate wrong swagger when use union type HOT 7
- Error on MacOS but not Stackblitz -- no transform has been configured -- due to PNPM hoisting HOT 1
- Very slow reaction on NX dev + loaders error
- How to customize error message? HOT 1
- SDK generator for `@WebSocketRoute()` functions
- How to properly use nestia in Docker HOT 1
- Enhance `@nestia/sdk` performance by abandoning `ts-node` HOT 5
- is tsconfig's strictPropertyInitialization property safe to set false? HOT 3
- binded arguments in the "path" between function's decorator and parameters' decorators are different HOT 11
- Text after the comma disappears in TypedFormData.Body HOT 2
- Cannot find module 'get-funtion-location' HOT 2
- In version `3.1.4` of @nestia/core, `nestia sdk` throws a `no transform has been configured` error. HOT 2
- [Bug Report] Parsing incorrect module paths HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestia.