Skip to content

Flaky operationIds for controller-methods with same name #885

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
kaibra opened this issue Sep 30, 2020 · 0 comments · Fixed by #886
Closed

Flaky operationIds for controller-methods with same name #885

kaibra opened this issue Sep 30, 2020 · 0 comments · Fixed by #886
Labels
bug Something isn't working

Comments

@kaibra
Copy link
Contributor

kaibra commented Sep 30, 2020

Describe the bug
Given a controller with methods of the same name, the operationIds are automatically build to be unqiue by appending an increasing number (eg "_1") to the method-name. The ids are not being build deterministically. Two runs can lead to different operationIds for a path in the spec.

To Reproduce

@RestController
public class OperationIdController {

    @GetMapping(path = "/test_0")
    public String opIdTest() {
        return "";
    }

    @GetMapping(path = "/test_1")
    public String opIdTest(@RequestParam String param) {
        return "";
    }

    @GetMapping(path = "/test_2") 
    public String opIdTest(@RequestParam Integer param) {
        return "";
    }

    @GetMapping(path = "/test_3")
    public String opIdTest(@RequestParam Boolean param) {
        return "";
    }

}

If you have a look at the OpenAPI calculated for this Controller, operationIds are flaky and can change for the given paths.

Expected behavior
Even though it may not make sense to have such a controller set up, the behaviour should be deterministic.
A given Controller should always lead to the same OpenAPI being calculated.

Additional context
There is already a sorting in place here: https://github.com/springdoc/springdoc-openapi/blob/master/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java#L413 before calculatePath is called.
But not here: https://github.com/springdoc/springdoc-openapi/blob/master/springdoc-openapi-webmvc-core/src/main/java/org/springdoc/webmvc/api/OpenApiResource.java#L244
And here: https://github.com/springdoc/springdoc-openapi/blob/master/springdoc-openapi-webflux-core/src/main/java/org/springdoc/webflux/api/OpenApiResource.java#L193

The EntrySet/Map from RequestMappingHandlerMapping does not seem to have a deterministic order.

@bnasslahsen bnasslahsen added the bug Something isn't working label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants