feat(swagger): warn when @ApiTags receives hierarchy fields#3924
Merged
kamilmysliwiec merged 2 commits intoMay 20, 2026
Merged
Conversation
@apitags accepts the object form { name, parent, kind } but normalizes each entry to its name, silently discarding parent and kind. The decorator-level metadata never reaches document.tags, so the OpenAPI 3.2 tag hierarchy is lost without any feedback. Emit a runtime warning when parent or kind is set on an @apitags object, pointing users to DocumentBuilder.addTag(), which is the supported way to define root-level tag hierarchy. Closes nestjs#3922
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
What is the current behavior?
@ApiTagsaccepts the object form{ name, parent, kind }(added in #3725, released in v11.4.0), but it normalizes every entry to itsname, silently discardingparentandkind:The decorator-level hierarchy metadata never reaches
document.tags, so the OpenAPI 3.2 tag hierarchy is lost with no feedback to the user. Root-level tag hierarchy is only honored when declared viaDocumentBuilder.addTag(name, description, { parent, kind }).Issue: #3922
What is the new behavior?
When
parentorkindis set on an@ApiTagsobject argument, the decorator now emits a runtime warning that points users toDocumentBuilder.addTag()— the supported way to define a root-level tag hierarchy.This implements the resolution agreed in #3922 ("Reject / warn"). String arguments and object arguments that only carry
nameare unaffected — no warning is emitted.Does this PR introduce a breaking change?
Tag normalization is unchanged; only a diagnostic warning is added.
Other information
Closes #3922. Tests added for the warn / no-warn cases in
test/decorators/api-use-tags.decorator.spec.ts.