Skip to content
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

Path variables parameters are not assigned correctly to endpoints #2031

Closed
khajduga opened this issue Jan 4, 2023 · 0 comments
Closed

Path variables parameters are not assigned correctly to endpoints #2031

khajduga opened this issue Jan 4, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@khajduga
Copy link

khajduga commented Jan 4, 2023

Bug description
When one controller method with endpoints definitions contains multiple paths with different path variables, then generated documentation shows that each endpoint has all of the path variables defined in that controller method.

To Reproduce

  1. Implement controller with only one @RequestMapping method with two paths that contain different path variables.
  2. Generate API docs and notice that each endpoint has all of the path variables.
  • What version of spring-boot you are using?
    2.5.5

  • What modules and versions of springdoc-openapi are you using?
    springdoc-openapi-ui 1.6.14

  • Sample code that reproduces the problem

@GetMapping(path = {"/orders/{shopName}", "/orders/{shopName}/customer/{customerId}"}, produces = MediaType.APPLICATION_JSON_VALUE)
public Object getOrders(@PathVariable(value = "customerId", required = false) Long customerId,
	                @PathVariable("shopName") String shopName) {

	if (Objects.isNull(customerId)) {
		return orderRepository.findAllByShopName(shopName);
	}

	return orderRepository.findAllByShopNameAndCustomerId(shopName, customerId);
}

Actual behavior
One of the endpoints was generated properly:
Orders-shopName-customerId

But other endpoint has two path variables, but it should contain only shopName path variable:
Orders-shopName

Expected behavior
Endpoint /orders/{shopName} should have only one parameter - shopName, parameters from other endpoints should not be visible.

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

No branches or pull requests

2 participants