Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 1000
Rajiv Kumar Avatar asked Sep 06 '25 03:09

Rajiv Kumar


1 Answers

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:

  • https://github.com/springfox/springfox/issues/2354
  • https://github.com/springfox/springfox/issues/2042

Closed issues:

  • https://github.com/springfox/springfox/issues/2541
  • https://github.com/springfox/springfox/issues/1874
like image 182
Daria Pydorenko Avatar answered Sep 07 '25 22:09

Daria Pydorenko