Search code examples
spring-bootspringfox

how to map two same URLs with different params in springfox with springboot rest controller?


Below are the 2 RequestMapping handler methods in my rest controller with the same value but different param.

@ApiOperation(value = "Query with name", nickname = "queryWithNameParam")
    @RequestMapping(value = "/query", params = "name",
            method = RequestMethod.GET)
    public void queryWithNameParam()


@ApiOperation(value = "Query with code", nickname = "queryWithCodeParam")
@RequestMapping(value = "/query", params = "code",
        method = RequestMethod.GET)
public void queryWithCodeParam()

I am able to invoke both the methods using resttemplate, but the API is not being shown on the browser when accessing swagger-ui.html

I am using springboot 2.0.3.RELEASE and springfox 2.9.2


Solution

  • Now there is only one option to fix this:

    1. Add springfox-swagger-ui-rfc6570 instead of springfox-swagger-ui as a dependency.

    2. Set enableUrlTemplating(true) in your docket configuration.

    Source: http://springfox.github.io/springfox/docs/current/#springfox-rfc6570-support-strong-incubating-strong

    Open issues in springfox Github project:

    Closed issues: