feat: add node decorator processor system for dynamic OpenAPI schema#7
Merged
Conversation
wRLSS
approved these changes
Jul 24, 2025
Collaborator
Author
…extensions This commit introduces a new node decorator processor system that allows dynamic extension of OpenAPI schemas through custom decorators. The system enables third-party services to inject custom metadata into generated OpenAPI specifications.
26d8ca9 to
d66bd9f
Compare
Collaborator
Author
b1ff
reviewed
Jul 25, 2025
| }; | ||
| processor(context); | ||
| } catch (error) { | ||
| throw new GenerateMetadataError(`Error in custom decorator processor for '${decoratorName}'`); |
There was a problem hiding this comment.
when this error is thrown it would be hard to debug given that original one is going to be missign
Collaborator
Author
There was a problem hiding this comment.
current GenerateMetadataError class isn't supposed to work with original Error object. I added node object as a second GenerateMetadataError constructor argument
| }; | ||
| } | ||
|
|
||
| export const RateLimitByUserIdProcessor: NodeDecoratorProcessor = (context: DecoratorProcessorContext) => { |
There was a problem hiding this comment.
does it mean that consumers must be adding separate decorators for documentation?
Collaborator
Author
There was a problem hiding this comment.
No, this is just as example. The device gets current decorators by provided name and then applies any modification to the openapi method metadata
b1ff
approved these changes
Jul 25, 2025
yehor-manzhula
approved these changes
Jul 28, 2025
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.
📋 Overview
This PR introduces a new option in metadata generator that allows custom decorators to dynamically extend OpenAPI schemas during the tsoa code generation process. This enables third-party services, middleware, and custom business logic to inject metadata directly into the generated OpenAPI specifications.
✨ Key Features
MetadataGeneratorOptions🔧 Implementation Details
Core Components
NodeDecoratorProcessor Interface
MetadataGenerator Integration
customDecoratorProcessorstoMetadataGeneratorOptionsMethodGenerator Enhancement
processCustomDecoratorsmethodUsage
1. Create Your Decorator & Processor
2. Register in Your Service
3. Use in Controllers
4. Generated OpenAPI Output