I'm facing a problem with swagger codegen generatered stubs. I have 2 services. First exposes REST api with two methods with path var and request param:
@GetMapping(value = "/start/{pathVar}/operators", params = "login")
public Operator getOperatorByLogin(
@ApiParam @PathVariable Long pathVar,
@ApiParam(required = true) @RequestParam String login) {
return operatorRepository.findDistinctByLogin(login);
}
and
@GetMapping(value = "/start/{pathVar}/operators", params = "ids")
public List<Operator> getOperatorsByIds(
@ApiParam @PathVariable Long pathVar,
@ApiParam( allowMultiple = true) @RequestParam List<Long> ids) {
return operatorRepository.findAllByOperatorIdIn(ids);
}
There are 2 endpoints with same URLs but diffrent params. Spring-web framework works with that. Next, I genereate OpenApi json and get 2 paths:
"/start/{pathVar}/operators{?ids}": ...
"/start/{pathVar}/operators{?login}": ...
Then, Im trying to generate with swagger-codegen-maven-plugin stubs for that endpoints and then I'm facing the problem.
Exception in thread "main" java.lang.IllegalArgumentException: Map has no value for '?login'
URLs in that form are hardcoded in generated classes.
(...)
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("pathVar", pathVar);
String path = UriComponentsBuilder.fromPath(
"/start/{pathVar}/opeartors{?login}").buildAndExpand(uriVariables).toUriString();
(...)
throws exception because of lacking of login map key-value in uriVariables.