We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My ValidationPipe setting is
app.useGlobalPipes(new ValidationPipe({ transform: true }));
My Dto is
import { PickType } from '@nestjs/swagger'; import { Expose, Transform } from 'class-transformer'; export class TestDto1 { @Expose() @Transform(() => { console.log('TestDto1 Transform'); return 1; }) version!: number; } export class TestDto2 extends PickType(TestDto1, ['version']) { @Transform(() => { console.log('TestDto2 Transform'); return 2; }) version!: number; } export class TestDto3PickTypeVersion extends PickType(TestDto2, ['version']) { @Transform(() => { console.log('TestDto3 Transform'); return 3; }) version!: number; } export class TestDto3ExtendVersion extends TestDto2 { @Transform(() => { console.log('TestDto3 Transform'); return 3; }) version!: number; }
My Controller is
@Controller('test') export class TestController { @Post('/pick-type-version') test1(@Body() testDto3PickTypeVersion: TestDto3PickTypeVersion) { return testDto3PickTypeVersion; } @Post('/extend-version') test2(@Body() testDto3ExtendVersion: TestDto3ExtendVersion) { return testDto3ExtendVersion; } }
When I call 「http://localhost:3000/pick-type-version」
TestDto3PickTypeVersion ignore TestDto2's @Transform.
When I call 「http://localhost:3000/extend-version」
TestDto2's @Transform would work.
If I change TestDto1 as
export class TestDto1 { @Expose() version!: number; }
TestDto2's @Transform would be work too.
https://github.com/KuanWenChen/swagger-issue
npm install npm run start:dev
goto website http://localhost:3000/swagger
Call Api and See log.
When I call「http://localhost:3000/pick-type-version」, I need to see 「TestDto2 Transform」
TestDto3PickTypeVersion should not ignore TestDto2's @Transform.
^7.1.13
10.2.7
v18.16.0
No response
The text was updated successfully, but these errors were encountered:
Would you like to create a PR for this issue?
Sorry, something went wrong.
OK, I has found the problem is happen at mapped-types function inheritTransformationMetadata
The problem is occurring at existingRules, and targetMetadataEntries are overwriting values taht with the same key ; they should merge.
I have created another issue for this problem.
nestjs/mapped-types#1212
No branches or pull requests
Is there an existing issue for this?
Current behavior
My ValidationPipe setting is
My Dto is
My Controller is
When I call 「http://localhost:3000/pick-type-version」
![image](https://private-user-images.githubusercontent.com/63909422/275790977-6569e84a-7557-4a9e-8034-f80ea0f168f1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NjY0NzUsIm5iZiI6MTcyNDU2NjE3NSwicGF0aCI6Ii82MzkwOTQyMi8yNzU3OTA5NzctNjU2OWU4NGEtNzU1Ny00YTllLTgwMzQtZjgwZWEwZjE2OGYxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDA2MDkzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNjZDlmNWVkNjVlMzgyZmViMjRmNDM4ODYyZWJiMTYxMmUwMmJkOTBhNzZhMWNmODc1ZTIwMmI1ZjU1M2I2YzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.BbSKgTc9vEr5xYsWHRDkXWWMEcprXASSAutrudDLPDM)
TestDto3PickTypeVersion ignore TestDto2's @Transform.
When I call 「http://localhost:3000/extend-version」
![image](https://private-user-images.githubusercontent.com/63909422/275791405-dcebbcb4-76bf-4546-a11f-22bbd0455fa2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NjY0NzUsIm5iZiI6MTcyNDU2NjE3NSwicGF0aCI6Ii82MzkwOTQyMi8yNzU3OTE0MDUtZGNlYmJjYjQtNzZiZi00NTQ2LWExMWYtMjJiYmQwNDU1ZmEyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDA2MDkzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNmNGExNmUxNzVlZGQ1NmMyNmZjZDc2NzNhMWI0OWMwNWIxOGRhYzI4YTg4MTU3NDljMTUyYjI2ZjIyZmQwNTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.0-UxM1HLcCWS1M-Q-1HfLiPo843MgoojhKz_PeKMqHk)
TestDto2's @Transform would work.
If I change TestDto1 as
TestDto2's @Transform would be work too.
Minimum reproduction code
https://github.com/KuanWenChen/swagger-issue
Steps to reproduce
npm install
npm run start:dev
goto website http://localhost:3000/swagger
![image](https://private-user-images.githubusercontent.com/63909422/275792134-778b128b-ba88-41d2-84f4-2fa4f7aa9aee.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NjY0NzUsIm5iZiI6MTcyNDU2NjE3NSwicGF0aCI6Ii82MzkwOTQyMi8yNzU3OTIxMzQtNzc4YjEyOGItYmE4OC00MWQyLTg0ZjQtMmZhNGY3YWE5YWVlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDA2MDkzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE0ZGE2ZDUzZDFhZThmMTFhYWEwN2VjNDk0M2NmY2JhZTIwMDhiMDU2NDkxYTJlNWM4ZjJiZTJjNDJkMjAwZjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jCxUbvNQQ47NM1hRZQHTNLM6ljGwIF9205Km9SYfuXU)
Call Api and See log.
Expected behavior
When I call「http://localhost:3000/pick-type-version」, I need to see 「TestDto2 Transform」
TestDto3PickTypeVersion should not ignore TestDto2's @Transform.
Package version
^7.1.13
NestJS version
10.2.7
Node.js version
v18.16.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: