0

I am trying to show the error response after success response in API Docs. for example:-

@ApiResponse({status: 401, description: 'invalid_client'}) (it's working)

but I want to give a customCode also like :-

@ApiResponse({status: 401, **customCode **: 'invalid_token', description: 'invalid_client'})

but I am getting an error on adding customCode:-

ERROR IS:- Argument of type '{ status: number; customCode: string; description: string; }' is not assignable to parameter of type 'ApiResponseOptions'. Object literal may only specify known properties, and 'customCode' does not exist in type 'ApiResponseOptions'.

I have tried to figure out from the Nestjs/swagger link but couldn't found the link for this issue.

https://docs.nestjs.com/recipes/swagger#responses

1 Answers1

0

You are getting this error because @ApiResponse() decorator expects only defined properties you can't add customCode in this decorator. but if you want you can assing whatever customCode in status: yourCustomCode that will work too or you can just return customCode in API response if it's needed.

Subham kuswa
  • 356
  • 4
  • 12