swagger icon indicating copy to clipboard operation
swagger copied to clipboard

Using @Req, @Res on NestJs controller kills swagger document creation

Open ThenmozhiGit opened this issue 7 years ago • 2 comments

Bug Report

Using @Req, @Res on NestJs platform-express controller kills swagger document creation

Current behavior

While using @Req/@Res in controller makes module initialization failed. The swagger page is not coming up. By removing these @Res from controller makes the code working fine.

Input Code

@Get('/contacts')
  @ApiOperation({ title: 'Get contacts details' })
  @ApiResponse({ status: 200, description: 'Success' })
  @ApiResponse({ status: 400, description: 'Forbidden.' })
  @ApiResponse({ status: 403, description: 'Bad request or Invalid Input' })
  @ApiResponse({ status: 500, description: 'Internal server error' })
  @ApiImplicitHeader({ name: 'authorization', description: 'authorization' })
  public getContacts(@Res() res: Response) {

    return res.status(200).send("contact");

  }

Expected behavior

This should work fine without any issues. Need a fix or workaround to resolve this issue.

Possible Solution

Environment

"@nestjs/common": "6.5.3",
"@nestjs/core": "6.5.3",
"@nestjs/platform-express": "6.5.3",
"@nestjs/swagger": "3.1.0",

"ts-node": "8.3.0", "typescript": "3.5.3"


Nest version: 6.5.3

 
For Tooling issues:
- Node version: v8.12.0
- Platform: Windows 

Others:

ThenmozhiGit avatar Aug 26 '19 10:08 ThenmozhiGit

Please, provide a minimal repository which reproduces your issue.

kamilmysliwiec avatar Aug 26 '19 10:08 kamilmysliwiec

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Apr 25 '20 11:04 lock[bot]