Add a decorator to change the name of a schema component name, instead of using the DTO name.
See original GitHub issueIs there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
Being able to decouple the name of the schema component definition from the DTO name would be very helpful.
This is useful in organizations that use a large API where several teams contribute contracts that may include conflicting schema/component names. So instead of forcing devs to name their DTOs in a way that avoids conflicts, this would allow devs to use whatever name is desired for their DTOs but then override the published component name with something else.
Describe the solution you’d like
Perhaps something like @ApiModel({ name: 'NonConflictingComponentName }), or something similar.
This could be added to classes, like so:
@ApiModel({ name: 'TeamAExample' })
export class ExampleDto {
...
}
Which would produce:
"components": {
"schemas": {
"TeamAExample": {}
Teachability, documentation, adoption, migration strategy
See above.
What is the motivation / use case for changing the behavior?
See above. Effectively, multi-tenant gateways that combine OpenAPI contracts together.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
NestJs/swagger: Define ref schemas without DTO classes
In the decorator, I create a DTO class with a predefined name, and map the properties from the plain object to the DTO...
Read more >Primer on Python Decorators
In this introductory tutorial, we'll look at what Python decorators are and how to create and use them.
Read more >Generic support for operationId · Issue #580 - GitHub
Issue description Hi guys, now the operationId is based on method name, but it's unusable when my controller methods is defined in a...
Read more >Tutorial: Create a more complex data model for an ASP.NET ...
In this tutorial you'll add more entities and relationships and you'll customize the data model by specifying formatting, validation, ...
Read more >Types and Parameters - OpenAPI - Documentation | NestJS
Hint To explicitly set the body definition use the @ApiBody() decorator (imported from the ... export class CreateCatDto { @ApiProperty() name: string; ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have not, unfortunately. My team is still blocked on seeing the PR merged. I might take a crack at creating a fresh PR soon if it looks like the current one has too many conflicts.
@adworacz it looks like #983 is still not merged. Have you found another solution for this?