OpenAPITools / OpenAPITools/openapi-generator
[REQ] Allow Maven Plugin to explicitly specify method name
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
The problem is that we have one Open API definition (i.e., one YAML file) describing two operations with the same name, each residing under a different URL hierarchy.
Examples:
- myEndpoint/myOperationContext1/myOperation
- myEndpoint/myOperationContext2/myOperation
Note that I have a different tag for the two operation contexts, i.e., I end up with two Java classes.
As I want to enforce meaningful Java method names, I define an operationId for each of them. As the operation is semantically doing the same thing, but in a different contexts, I would like to have the two methods to have the same name. Java-wise this is fine, as the two methods reside in different classes. However, Open API requires the operationId to be globally unique (I guess globally refers to "per file").
As a consequence, I cannot specify two operationIds with the same name and cannot name my methods properly.
Describe the solution you'd like
I´'d like to have a means where I can map operationIds to Java method names.
So I could assign the two operationIds myOperation1 and myOperation2 and map them both to the method name myOperation.
Describe alternatives you've considered
I could create two YAML files, one for each operation context. But this has drawbacks, like redundant information in each YAML file and also that the Maven Plugin only supports to name one YAML file per entry in the POM.xml
I can also enter a character in the operationId that will be removed during code generation.
For instance, I defined operationIds myOperaton and my.Operation. This counts as two different operationIds and leads to the same Java method. This is ugly, but easy and produces the desired outcome.
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Maven Plugin configuration and the operationId handling used during Java generation. Trace how entries from POM.xml reach generated method names, then run the relevant Maven Plugin tests. Done means two distinct operationIds can map to the same Java method name without breaking generation or validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100