question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a decorator to change the name of a schema component name, instead of using the DTO name.

See original GitHub issue

Is 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
adworaczcommented, May 19, 2022

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.

0reactions
felixhagspielcommented, May 11, 2022

@adworacz it looks like #983 is still not merged. Have you found another solution for this?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found