Skip to content

feat(decorators): add style and explode options to @ApiProperty#3789

Open
JadenKim-dev wants to merge 1 commit intonestjs:masterfrom
JadenKim-dev:feat/support-deepobject-style-in-api-property
Open

feat(decorators): add style and explode options to @ApiProperty#3789
JadenKim-dev wants to merge 1 commit intonestjs:masterfrom
JadenKim-dev:feat/support-deepobject-style-in-api-property

Conversation

@JadenKim-dev
Copy link
Copy Markdown

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?

@ApiProperty does not accept style or explode options. When using a nested object as a query parameter (e.g. Geolocation inside a QueryDto), there is no way to specify style: 'deepObject' without a @ts-expect-error workaround.

This causes Swagger UI to generate flat query strings like ?latitude=5&longitude=1 instead of ?geolocation[latitude]=5&geolocation[longitude]=1.

Issue Number: #3495

What is the new behavior?

ApiPropertyCommonOptions now includes optional style (typed as ParameterStyle) and explode (typed as boolean) properties. These values are passed through to the OpenAPI ParameterObject at the top level, enabling proper serialization of nested query parameters.

Example usage:

@ApiProperty({
  required: false,
  type: () => GeolocationDto,
  style: 'deepObject',
  explode: true,
})
geolocation?: GeolocationDto;

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Add `style` and `explode` properties to `ApiPropertyCommonOptions`,
allowing nested object query parameters to be serialized using
OpenAPI serialization styles such as `deepObject`.
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