2

I want to do something like create two method for same url pattern with different arguments

@RequestMapping(value = "/searchUser", params = "userID")
public String searchUserById(@RequestParam long userID, Model model) {
  // ...
}

@RequestMapping(value = "/searchUser", params = "userName")
public ModelAndView searchUserByName(@RequestParam String userName) {
  // ...
}

Spring supports this and it works fine. SpringDoc does not. It creates a single endpoint with 2 parameters.Is this a known issue?

Mike Rother
  • 591
  • 4
  • 16
  • Have you found solution to this? I have same issue with `@GetMapping` methods having same path but different `@RequestParam` – pixel Jun 21 '22 at 18:05

1 Answers1

0

This is supported, but you will have to use swagger @Operation to describe your methods in one path.

One of the OpenAPI 3 rules.

Two POST methods for the same path are not allowed – even if they have different parameters (parameters have no effect on uniqueness).

More details are available on OpenAPI 3 site.

This has been explained here: https://github.com/springdoc/springdoc-openapi/issues/580

brianbro
  • 4,141
  • 2
  • 24
  • 37