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

Infer operation_id from handler method name #4

Open
slinkydeveloper opened this issue Apr 25, 2023 · 3 comments · May be fixed by #10
Open

Infer operation_id from handler method name #4

slinkydeveloper opened this issue Apr 25, 2023 · 3 comments · May be fixed by #10
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@slinkydeveloper
Copy link
Contributor

Hi, would it be possible to default the operation_id to the handler method name?

@Flowneee
Copy link
Owner

Sounds good, but I am not sure. I can see how someone structure their code so each handler is located in separate files, where each contain handler function

// src/api/users.rs
async fn handler(...) { ... }

// src/api/groups.rs
async fn handler(...) { ... }

And it is clearly stated in specification The id MUST be unique among all operations described in the API, also I see that could cause problems with code generation.

This could be some optional behavior enabled with feature or flag in builder, not sure how to do that better.

@slinkydeveloper
Copy link
Contributor Author

I see your point @Flowneee, on the other hand I guess one can still override the operation_id using the macro attribute. Also, I would expect such clash to be checked by the OpenAPIBuilder (even manually adding the routes).

@Flowneee
Copy link
Owner

Flowneee commented May 2, 2023

Also, I would expect such clash to be checked by the OpenAPIBuilder

That may be a good idea, at least as assert in debug builds, or with a feature.

@slinkydeveloper slinkydeveloper linked a pull request Sep 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants