Skip to content

fix(swagger): support const enum query params#3910

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
yudin-s:fix/query-param-const-enum-schema
May 14, 2026
Merged

fix(swagger): support const enum query params#3910
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
yudin-s:fix/query-param-const-enum-schema

Conversation

@yudin-s

@yudin-s yudin-s commented May 14, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

When SWC emits const enum metadata as an object for a query parameter type, SchemaObjectFactory#createQueryOrParamSchema() treats that object as a literal object schema. That produces nested property metadata instead of an OpenAPI enum schema for the parameter.

Issue Number: Fixes #3909

What is the new behavior?

createQueryOrParamSchema() now recognizes const-enum-like object metadata before the generic object literal branch and emits a parameter schema with type and enum values.

A regression test covers a query parameter whose type is a const-enum-style object.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Local checks:

  • npm test -- test/services/schema-object-factory.spec.ts
  • npm run build
  • npm run lint (passes with existing warnings outside this change)
  • git diff --check

@kamilmysliwiec kamilmysliwiec marked this pull request as ready for review May 14, 2026 10:08
@kamilmysliwiec kamilmysliwiec merged commit 0d79a3c into nestjs:master May 14, 2026
1 check passed
@kamilmysliwiec

Copy link
Copy Markdown
Member

lgtm

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.

const enum objects not recognized in createQueryOrParamSchema (SWC compatibility)

2 participants