Skip to content

fix enum issue#3774

Open
SupunGeethanjana wants to merge 1 commit intonestjs:masterfrom
SupunGeethanjana:issue/3772
Open

fix enum issue#3774
SupunGeethanjana wants to merge 1 commit intonestjs:masterfrom
SupunGeethanjana:issue/3772

Conversation

@SupunGeethanjana
Copy link
Copy Markdown

@SupunGeethanjana SupunGeethanjana commented Mar 15, 2026

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #3772

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@SupunGeethanjana
Copy link
Copy Markdown
Author

Walkthrough: Fix Bug #3772 - Boolean Enum Type Mapping

I have fixed the issue where @ApiProperty({ type: Boolean, enum: [true] }) incorrectly generated a number type in the OpenAPI document.

Changes Made

Utilities

enum.utils.ts

  • Updated getEnumType to explicitly check for boolean values in enums.
  • Added support for returning the 'boolean' type when boolean values are detected.
  • Updated the return type of getEnumValues to include boolean[].

Verification Results

Automated Tests

Reproduction Test

I created a temporary test case test/reproduce_issue_3772.spec.ts that confirmed the bug:

  • Before Fix: Expected type: "boolean", but received type: "number".
  • After Fix: Test passed with type: "boolean".

Unit Tests

Ran all 160 unit tests using npm test:

  • Result: 160 passed, 0 failed.

E2E Tests

Ran all e2e tests using npm run test:e2e:

  • Result: 102 passed, 0 failed.

Summary

The reported bug was due to a missing case in the type inference logic for enums. By adding an explicit check for booleans in getEnumType, the OpenAPI generator now correctly identifies boolean enums.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant