Comments (5)
I find out what was wrong:
I shouldn't use
import { IntersectionType } from '@nestjs/swagger'
instead of that use from mapped-types
import { IntersectionType } from '@nestjs/mapped-types'
mapped-types is working as expect.
@Post()
@UsePipes(new ValidationPipe({ transform: true }))
create(@Body('dto') dto: combineDto) {
Logger.debug(dto);
return 'OK';
}
Response:
OK
<!-- POST http://localhost:3000/ -->
<!-- HTTP/1.1 201 Created -->
<!-- X-Powered-By: Express -->
<!-- Content-Type: text/html; charset=utf-8 -->
<!-- Content-Length: 2 -->
<!-- ETag: W/"2-nOO9QiTIwXgNtWtBJezz8kv3SLc" -->
<!-- Date: Mon, 26 Oct 2020 19:44:36 GMT -->
<!-- Connection: keep-alive -->
<!-- Request duration: 0.053106s -->
[Nest] 15392 - 10/26/2020, 8:48:10 PM [NestFactory] Starting Nest application...
[Nest] 15392 - 10/26/2020, 8:48:10 PM [InstanceLoader] AppModule dependencies initialized +13ms
[Nest] 15392 - 10/26/2020, 8:48:10 PM [RoutesResolver] AppController {}: +6ms
[Nest] 15392 - 10/26/2020, 8:48:10 PM [RouterExplorer] Mapped {, GET} route +3ms
[Nest] 15392 - 10/26/2020, 8:48:10 PM [RouterExplorer] Mapped {, POST} route +2ms
[Nest] 15392 - 10/26/2020, 8:48:10 PM [NestApplication] Nest application successfully started +3ms
[Nest] 15392 - 10/26/2020, 8:48:10 PM Listen to port : 3000 +5ms
[Nest] 15392 - 10/26/2020, 8:49:12 PM Object:
{
"table": [
1,
2,
3,
4
],
"table2": [
1,
2,
3,
4
],
"text": "test"
}
+61848ms
from mapped-types.
So looks like I was too fast, because today morning I realize that Swagger will not work with that :D
from mapped-types.
Lets' track this here nestjs/swagger#1015
from mapped-types.
The issue is still present on "@nestjs/mapped-types": "^0.1.1"
.
I have a use case similar to the one above, except I'm validating query params.
from mapped-types.
If you face any issue, please, create a separate ticket with a minimal reproduction repository.
from mapped-types.
Related Issues (20)
- Class 'CreateUserDto' incorrectly extends base class 'RemoveFieldsWithType<Partial<User>, Function>'. Property 'status' is optional in type 'CreateUserDto' but required in type 'RemoveFieldsWithType<Partial<User>, Function>' HOT 6
- PartialType and IntersectionType doesn't work as expected HOT 9
- Extending using PartialType, OmitType… doesn't copy properties decorators HOT 3
- PickType ignore parent's @Transform when grandparent use @Transform
- Breaking change in 2.0.3 for override fields HOT 5
- Using a PartialType inside a PickType will result in a type error. HOT 1
- IntersectionType breaks returning value of methods HOT 4
- Module '"@nestjs/mapped-types"' has no exported member 'PartialType'. HOT 3
- Create build using latest code HOT 5
- Mapped Types are not transformed with [email protected]+ in browser HOT 1
- Can't inherit getter/setter and function HOT 2
- PartialType can't work with class-validator HOT 1
- `IntersectionType` clause for more than 4 classes is not available in the npm version HOT 4
- Remove @nestjs/common dependency HOT 2
- Could not resolve dependency: peerOptional class-validator@"^0.11.1 || ^0.12.0 || ^0.13.0" from @nestjs/[email protected] HOT 5
- Support for class-validator 0.14.0 HOT 4
- Install fails when class-validtor 0.14.0 already installed HOT 1
- Update security dependencies HOT 4
- `prettier/@typescript-eslint` in ESLint config now throws error HOT 1
- Update the class-validator dependency to 0.14.0 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 mapped-types.