Skip to content

Path variables parameters are not assigned correctly to endpoints #2031

Closed
@khajduga

Description

@khajduga

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions