Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger decorator @ApiHeader is not including header on request #2906

Open
3 of 15 tasks
douglasjunior opened this issue Apr 2, 2024 · 2 comments
Open
3 of 15 tasks

Comments

@douglasjunior
Copy link

douglasjunior commented Apr 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Swagger decorator @ApiHeader is not including header on request

Code

@Controller('template')
export class TemplateController {

  @Get('test')
  @ApiHeader({
    name: 'accept',
  })
  async test(@Headers('accept') acceptHeader: string) {

    return `ok: ${acceptHeader}`;
  }

}

Result

image

Minimum reproduction code

https://codesandbox.io/p/devbox/green-cache-5xjgvc

Steps to reproduce

Just create a new NestJS project and add a new Controller like TemplateController above.

Expected behavior

Expect that Swagger UI to include the proper accept value on request.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

@nestjs/swagger

NestJS version

10.3.3

Packages versions

    "@nestjs/common": "10.3.3",
    "@nestjs/config": "3.2.0",
    "@nestjs/core": "10.3.3",
    "@nestjs/platform-express": "10.3.3",
    "@nestjs/swagger": "7.3.0",
    "class-transformer": "0.5.1",
    "class-validator": "0.14.1",

Node.js version

18.12.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/nest Apr 3, 2024
@letsaguiar
Copy link

this problem is specifically related to the 'accept' header. It works fine with other headers, but it doesn't with the accept header

Screenshot from 2024-04-15 11-16-52

Screenshot from 2024-04-15 11-17-20

@douglasjunior
Copy link
Author

Confirmed in the provided example: https://codesandbox.io/p/devbox/green-cache-5xjgvc

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants