3

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?

1
  • Have you found solution to this? I have same issue with @GetMapping methods having same path but different @RequestParam Commented Jun 21, 2022 at 18:05

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Nothing to do with POST methods. Same with @GetMapping
This honestly sucks. The OAS3 spec is dumb in this regard.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.