I’m using Nest.js for the first time and migrating a legacy node.js API. I’m creating the first route to make sure this will preserve the OpenAPI spec capabilities. I’ve created the controller with one route that accepts a JSON body. The body class uses decorators from @nestjs/swagger
, and I am able to see the schema show up in the Swatter UI when using the @Body
decorator:
@Controller('my-api')
export class CertificatesController {
@ApiOperation({ })
@Post()
async create(
@Req() req: Request,
@Res() res: Response,
@Body() body: TheBody,
): Promise<Result> {
//...
}
}
However, one thing that the original API had was a description
property for the body parameter, and there doesn’t seem to be a way to add one to my TheBody
class. I’ve tried adding an ApiBody
decorator to the method, and that lets me add a description, but that shadows the schema of body
, causing it to show the type as a string instead of the schema defined by TheBody
.
How do you add a description to your body parameter in Nest.js without removing the type reflection provided by the @Body
decorator?