Skip to content

Names of derived methods are ending with numbers (Java + Spring) #6173

@illidan80

Description

@illidan80

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions