feat(@ApiExtension): When used on a controller it applies to all methods#3485
Merged
kamilmysliwiec merged 3 commits intonestjs:masterfrom Oct 10, 2025
Merged
Conversation
Contributor
Author
Docs are a separate repo right? I'm happy to update those if this looks like something that will accepted. |
2ab32e8 to
a906676
Compare
a906676 to
218c820
Compare
drewish
commented
Jun 18, 2025
| }, | ||
| "x-schema-extension-multiple": { | ||
| "test": "test*2" | ||
| }, |
Contributor
Author
There was a problem hiding this comment.
The order of these extensions changed but I modified the values to make it clear they aren't affected.
drewish
commented
Jul 1, 2025
Co-authored-by: andrew morton <drewish@katherinehouse.com>
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 Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
If you try to use the
@ApiExtension()decorator at the controller level it has no effect on the OpenAPI file. It only has an effect on methods.So using it at the controller level like this would have no effect on the create operation.
Issue Number: N/A
What is the new behavior?
Now when
@ApiParam()decorator is used on a controller the extension property is added to all the operations implemented by the controller.The above example would apply the extension to the operation:
If you apply the same extension decorator at the method level it will override the controller level value. I spent a little time trying to merge the values but it added quite a bit of complexity and seemed like It could give some surprising results.
Does this PR introduce a breaking change?
Other information