#How can I get @nest/mapped-types and @nest/swagger to work together?

7 messages · Page 1 of 1 (latest)

bright mist
#

I would like to use PickType in one of my DTOs but here is the issue:
importing PartialType from @nestjs/mapped-types works, but in the openapi this DTO is typed as {} empty object
importing PartialType from @nestjs/swagger fixes openapi issue, but on runtime the DTO properties are not optional (e,g, transformers don't seem to be mapped)

hushed zephyr
#

with swagger, you should only use @nestjs/swagger in place of @nestjs/mapped-types. If the inherited properties are not made optional, then that's a bug and needs to be reported (along with a reproduction of the issue)

bright mist
#

Makes sense now, just noticed my mistake there thanks for the help @hushed zephyr

#

But the one thing I can't understand is when I use PartialType from @nestjs/swagger can I specify the properties to have IsOptional from class-validator too? Is that possible? @hushed zephyr

#

If the inherited properties are not made optional, then that's a bug
Are they supposed to be made optional in terms of class-validator?

hushed zephyr