#No Swagger documentation for PATCH endpoint with a partial mapped-type update DTO

3 messages · Page 1 of 1 (latest)

upper marlin
#

When it comes to my POST endpoint, the documentation is generated for the create DTO. However, it doesn't work for the update DTO which is a mapped partial type from the create DTO.

Only the additional property is documented (check the screenshots). What seems to be the problem here? For further context, all libraries installed are on the latest version and I'm using SWC compiler.

controller.ts
`// ...some code on imports and implementation of class name

@Post()
async createOneOrMany(@Body() createDto: CreateEntityDto) {
console.log(createDto);
return createDto;
}

@Patch()
async update(@Body() updateDto: UpdateEntityDto) {
console.log(updateDto);
return updateDto;
}`

update-entity.dto.ts
`import { PartialType } from '@nestjs/swagger';
import { CreatePhysicianDto as CreateEntityDto } from './physician.dto';

export class UpdateEntityDto extends PartialType(CreateEntityDto) {
someAdditionalProperty: string;
}`

also, is this line of code necessary in main.ts even if I'm not on a monorepo? (reference: https://docs.nestjs.com/openapi/cli-plugin#swc-builder)

import metadata from './metadata'; // ... some code await SwaggerModule.loadPluginMetadata(metadata); // ...some code await app.listen(configService.get('PORT') || 3000);

upper marlin
#

Update: I just found out that the issue does not happen if I disable SWC as compiler. Mapped partial type dto is being documented. How can I make this work without disabling SWC?

stone wing