Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default @ApiTag to controller name #3011

Closed
1 task done
nhomble opened this issue Jul 18, 2024 · 2 comments
Closed
1 task done

default @ApiTag to controller name #3011

nhomble opened this issue Jul 18, 2024 · 2 comments
Labels

Comments

@nhomble
Copy link
Contributor

nhomble commented Jul 18, 2024

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

The current strategy (or lack thereof) doesn't give nestjs adopters a way to easily lead developments teams to easily group their api routes in a service. We would like to guide developers with better convention, and a common solution we have seen is grouping by the controller name.

We see this grouping inherent to the controller class you have registered in the nest module, so redefining an ApiTag decorator is not appealing.

Describe the solution you'd like

I think another parameter could be added to SwaggerCustomOptions like

{
  apiTagStrategy?: { strategy: 'NONE' } | { strategy: 'CONTROLLER_NAME' }
}

when it's undefined, fallback to the existing NONE strategy

Teachability, documentation, adoption, migration strategy

The change is backwards compatible so no migration necessary, and this could added to the existing nestjs swagger recipe section.

What is the motivation / use case for changing the behavior?

For services with enough routes, it is disorganized to have all definitions under the default group. So far, all of our use cases are sufficed by annotating the controllers (with @ApiTag) with our controller name.


It's tedious to ask developers to re-annotate their controllers with another grouping when they've already done a reasonable grouping at the class level in the first place.

@kamilmysliwiec
Copy link
Member

Sounds useful

Would you like to create a PR for this issue?

@kamilmysliwiec
Copy link
Member

Let's track this here #3017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants