Skip to content

[REQ] Possibility to remove service name from method name #11783

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

Closed
angelaki opened this issue Mar 3, 2022 · 8 comments
Closed

[REQ] Possibility to remove service name from method name #11783

angelaki opened this issue Mar 3, 2022 · 8 comments

Comments

@angelaki
Copy link
Contributor

angelaki commented Mar 3, 2022

Just like probably many out there I needed to add the endpoint name to the operationId (OAI/OpenAPI-Specification#381) to keep them unique.

Having two services (e.g. Service1 & Service2) both having a method "get" I get two operationIds (e.g. Service1_get & Service2_get).

The prefix (Service1_, Service2_) is totally useless but requred by OpenAPI. Now the service clients will get generated like

Service1 {
   Service1_get() { ... }
}

Service2 {
   Service2_get() { ... }
}

Is there maybe a possibility already to make both the methods just get named "get()"? Any ideas on this?

@spacether
Copy link
Contributor

spacether commented Jul 28, 2022

I am working on this for the python-experimental client in: #13007
One will be able to use it like:

from package.paths import PathValues
from package.apis.path_to_api import path_to_api
path_enum = PathValues("some/path")
api = path_to_api[path_enum]
# api has .post/put/patch etc methods on it

@angelaki
Copy link
Contributor Author

@spacether or anyone else here having this issue ... Any news / ideas on this?

@wing328
Copy link
Member

wing328 commented Apr 22, 2024

@angelaki have you tried the operationIdNameMappings option to match the operationId to whatever method name you want?

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#name-mapping

@angelaki
Copy link
Contributor Author

Thats a great idea! But I'd need some kind of replace / regex, since I have several of Methods!

@wing328
Copy link
Member

wing328 commented Apr 22, 2024

ok. have you tried the --remove-operation-id-prefix option?

ref: https://openapi-generator.tech/docs/usage/

@angelaki
Copy link
Contributor Author

Works like a charm - thank you very much! What exactly does this option do? The docs aren't very transparent here. Does it look for a specific character? Or a name being repeated with every method?

@wing328
Copy link
Member

wing328 commented Apr 22, 2024

remove operationId prefix (e.g. user_getName => getName)

ref: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.md

@wing328 wing328 closed this as completed Apr 22, 2024
@wing328
Copy link
Member

wing328 commented Apr 22, 2024

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

No branches or pull requests

3 participants