I want to add some custom example to an ApiResponse. I tried the following code but the output is the default:
@Get('/:id')
@ApiResponse({
status: HttpStatus.OK,
type: ResponseDto,
})
@ApiResponse({
description: 'Failure retrieving card details',
status: HttpStatus.BAD_REQUEST,
schema: {
$ref: getSchemaPath(ErrorMessageDto),
example: {
errors: [
{
message: 'Invalid format',
property: 'id',
detail: null,
},
],
},
},
})
public async someMethod(): Promise<ResponseDto> {
return ...
}
I cannot put the example in ErrorMessageDto because will be used in all endpoints, and I want to put deferents examples in deferents endpoints.
I know that swagger natively allows you to do this. how do it via nestjs?