nestjs / swagger

OpenAPI (Swagger) module for Nest framework (node.js) :earth_americas:

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swagger decorator @ApiHeader is not including header on request

douglasjunior opened this issue · comments

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

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