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 function name #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

slinkydeveloper
Copy link
Contributor

@slinkydeveloper slinkydeveloper commented Sep 27, 2023

Fix #4

@slinkydeveloper
Copy link
Contributor Author

@Flowneee

@Flowneee
Copy link
Owner

I think generation of operationId should be an opt-in behavior, since it is not mandatory in specification. There 2 things needs to be done here IMO:

  • parameter in Builder, which will enable generation of operationId from function names (.generate_operarion_id(bool)), which is false by default (which can be later changed in major releases)
  • possibility to pass None (or empty string), which will not generate operationId property at all for current operation.

Also please describe changes in CHANGELOG

@slinkydeveloper
Copy link
Contributor Author

@Flowneee how would you propagate a builder config option to the macro? I guess we could modify the signature of OperationGenerator into something like:

pub type OperationGenerator = fn(&mut Components, &BuilderOptions) -> Result<Operation, anyhow::Error>;

And then this BuilderOptions will take care of carrying the generate_operation_id_from_function_name field, which I can if-then within the generated code. WDYT?

@Flowneee
Copy link
Owner

@slinkydeveloper Yeah, I thought about something like that. We can then expand set of options, allowing to customize spec generation further. For now, since it is single parameter, I think BuilderOptions should be hidden inside OpenApiBuilder, and this option exposed as method of OptnApiBuilder::infer_operation_id.

But rename generate_operation_id_from_function_name to something shorter like infer_operation_id )

@Flowneee Flowneee force-pushed the master branch 3 times, most recently from 6e0e554 to 3d25438 Compare July 23, 2024 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infer operation_id from handler method name
2 participants