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

Merging middleware information with routes #939

Open
Zambiorix opened this issue May 31, 2021 · 2 comments
Open

Merging middleware information with routes #939

Zambiorix opened this issue May 31, 2021 · 2 comments
Labels

Comments

@Zambiorix
Copy link

Is your feature request related to a problem? Please describe.

I am using Swag with Echo and I've implemented several middleware, like authorization, rate limit, logging and lots more.
These middleware sometimes use header and/or parameter information and can produce failures.

Now when I describe a route I have to remember to include all the possible information from the used middlewares.
That is prone to errors, if I forget something or if the middleware is updated...

Unless I am mistaken, there is no way of merging middleware information with routes..
I would love to see a solution that solves this problem

Describe the solution you'd like

Maybe include 2 new tags:

For middleware description:

// @Middleware myMiddleware
// @Failure 503 {object} httputil.HTTPError

For route description:

// @MiddlewareRef myMiddleware

So that information from the middleware is merged with the route information

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Thanks!

@ubogdan
Copy link
Contributor

ubogdan commented Jul 27, 2021

I think a better idea is to use an @template annotation and include that template in your route/controler definition.

Do you think you contribute with a PR for this issue?

@addshore
Copy link

I have a similar usecase for such as feature, either middleware-focused, or template focused (or perhaps some sort of global response template)

Right now I have to define the following in all routes, which are actually specific to a middleware

// @Failure 429 {string} string "Limit exceeded"
// @Header       429  {integer}  X-Ratelimit-Limit
// @Header       429  {integer}  X-Ratelimit-Remaining
// @Header       429  {integer}  X-Ratelimit-Reset

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

3 participants