Skip to content

@ApiProperty({ type: Boolean, enum: [true] }) generates a value of type number in the OpenApi doc #3772

@thomaslule

Description

@thomaslule

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When describing a property like this:

@ApiProperty({ type: Boolean, enum: [true] })
hello = true;

The generated openapi property looks like this:

{ "hello": { "type": "number", "enum": [true] } }

Notice the number type where it should be boolean.

Minimum reproduction code

https://github.com/thomaslule/nestjs-boolean-enum

Steps to reproduce

  1. npm i
  2. npm run start:dev
  3. navigate to http://localhost:3000/api-json
  4. notice that the type of hello is number instead of boolean

Expected behavior

I expect this generated openapi property:

{ "hello": { "type": "boolean", "enum": [true] } }

Package version

11.2.6

NestJS version

11.0.1

Node.js version

24.2.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

I also tried to write @ApiProperty({ type: 'boolean', enum: [false] }) and obtained the same result.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions