OpenAPITools / OpenAPITools/openapi-generator
Names of derived methods are ending with numbers (Java + Spring)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Let's assume I have the following controller of version 1 (Java + Spring):
@RestController
@RequestMapping("/v1")
public class MyControllerV1 {
@GetMapping("/count")
public MyResponseV1 getCount() throws Exception {
// calculate and return count
}
}
Which generated into something like this:
public MyResponseV1 getCountUsingGET() throws RestClientException {
...
}
Now, I decided to expose new API which extends the existing one:
@RestController
@RequestMapping("/v2")
public class MyControllerV2 extends MyControllerV1 {
@GetMapping("/something-else")
public MyOtherResponseV1 doSomethingElse() throws Exception {
// ...
}
}
When I generating code based on those two controllers I got generated both MyControllerV1 and MyControllerV2 (as expected). MyControllerV1 is the same as previously, but MyControllerV2 looks like this:
public MyResponseV1 getCountUsingGET1() throws RestClientException {
...
}
public MyOtherResponseV1 doSomethingElseUsingGET() throws RestClientException {
...
}
The expected: derived class will have exactly same method names as the base one.
The actual: derived class has its derived methods ending with numbers.
The whole idea of deriving approach is to extend existing API with less breaking changes as possible. Now everyone who migrates to MyControllerV2 has to rename all existing methods.
This is very annoying. I not sure if is this bug or feature, but is there anything I can do to get desired behavior? Or this is indeed bug?
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
The issue provides Java and Spring controller examples but names no repository files or tests. Start by reproducing the generated MyControllerV1 and MyControllerV2 methods, then trace the generator's method-name collision handling; done means inherited methods retain the base names without numeric suffixes while new methods remain distinct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100