Skip to content

fix: missing ApiProperty enum undefined on array handling#3590

Merged
kamilmysliwiec merged 2 commits intonestjs:masterfrom
pvdspek:fix-apiproperty-array-with-undefined-enum
Oct 16, 2025
Merged

fix: missing ApiProperty enum undefined on array handling#3590
kamilmysliwiec merged 2 commits intonestjs:masterfrom
pvdspek:fix-apiproperty-array-with-undefined-enum

Conversation

@pvdspek
Copy link
Copy Markdown
Contributor

@pvdspek pvdspek commented Oct 15, 2025

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?

When using enum: undefined on an array property:

@ApiProperty({
  type: 'string',
  isArray: true,
  enum: undefined
})
testStringArray: string[];

the resulting schema incorrectly becomes:

{
  "testStringArray": {
    "type": "array",
    "items": {
      "type": "number",
      "enum": []
    }
  }
}

This is similar to the bug fixed in #3232, but was not fixed for the case where the property is an array.

Issue Number: N/A

What is the new behavior?

After this fix the resulting schema correctly becomes:

{
  "testStringArray": {
    "type": "array",
    "items": {
      "type": "string"
    }
  }
}

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

…dling

Fixes issue where an undefined enum option property incorrectly results in array items changed to `{type: 'number', enum: []}`.
Adds test to check for correct schema when undefined enum on array property is used.
@kamilmysliwiec kamilmysliwiec merged commit c8352cb into nestjs:master Oct 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants