Swagger: Open API doc not generated for PartialType DTO

Created on 6 Dec 2020  路  4Comments  路  Source: nestjs/swagger

Bug Report

When using the PartialType for DTO, it is not reflected in the OpenAPI documentation.
https://docs.nestjs.com/openapi/mapped-types

Input Code

export class CreateUserDTO {
  @IsNotEmpty()
  @IsString()
  name: string;
}

export class UpdateUserDTO extends PartialType(CreateUserDTO) {
}

Current behavior


UpdateUserDTO schema in the OpenAPI documentation is missing the name property

Expected behavior

OpenAPI document to have name: string in UpdateUserDTO Schema. But missing the name property in the generated schema.

Environment


Nest version: 7.0.0


For Tooling issues:
- Node version: 12.18.1
- Platform: Windows

Others:

needs clarification

Most helpful comment

Import PartialType from @nestjs/swagger

All 4 comments

Please provide a minimum reproduction repository.

Sample Repo: https://github.com/kalaivanan-muthusamy/nestjs-swagger-issue-1074

image
image

I am expecting the properties in CreateUserDto should also exist in UpdateUserDto as optional. But the properties are not present in the schema

Import PartialType from @nestjs/swagger

I missed it completely. It is clearly mentioned in the document. Thanks for the wonderful document.

This should be the issue with cli then. As CLI is importing the PartialType from @nestjs/mapped-types instead @nestjs/swagger.

Opened the PR for the expected change
https://github.com/nestjs/schematics/pull/545

Was this page helpful?
0 / 5 - 0 ratings

Related issues

patilrevansidh picture patilrevansidh  路  4Comments

Diluka picture Diluka  路  4Comments

KatSick picture KatSick  路  3Comments

ericzon picture ericzon  路  4Comments

malbertSC picture malbertSC  路  5Comments