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

Find a way to rename OpenAPI object and operation globally #619

Closed
Tracked by #745
ollyde opened this issue Jan 10, 2024 · 3 comments · Fixed by #784 or #785
Closed
Tracked by #745

Find a way to rename OpenAPI object and operation globally #619

ollyde opened this issue Jan 10, 2024 · 3 comments · Fixed by #784 or #785
Labels
enhancement New feature or request

Comments

@ollyde
Copy link

ollyde commented Jan 10, 2024

On the swagger spec the operationIds are very long

Screenshot 2024-01-10 at 18 47 46

This results in very long auto generated code

Screenshot 2024-01-10 at 18 48 07

We need away to reduce it.

@chrislearn
Copy link
Member

You can rename your operation_id for example:

#[endpoint(operation_id="AAAAAAA", tags("todos"), status_codes(200, 404))]
pub async fn update_todo(id: PathParam<u64>, updated: JsonBody<Todo>) -> Result<StatusCode, StatusError> {
...
}

@ollyde
Copy link
Author

ollyde commented Jan 11, 2024

@chrislearn yes indeed but it’s also on objects like return types; would be nice to config the root so it’s smaller across the whole project automatically :-)

@chrislearn chrislearn changed the title [Custom operationIds] Find a way to rename object and operation globally Jan 15, 2024
@chrislearn chrislearn added the enhancement New feature or request label Jan 15, 2024
@chrislearn chrislearn changed the title Find a way to rename object and operation globally Find a way to rename OpenAPI object and operation globally Jan 15, 2024
@chrislearn chrislearn mentioned this issue Apr 4, 2024
7 tasks
@chrislearn chrislearn reopened this May 23, 2024
@chrislearn
Copy link
Member

You can use your custom Namer to define your rename rule globally.

https://github.com/salvo-rs/salvo/blob/main/crates/oapi/src/naming.rs

I just don't have time to polish the documentation. PRs for documentation are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants