Path variable mapped improperly in swagger-ui
Describe the bug
I have simple controller in Kotlin
@Operation(summary = "Get company details", description = "Get company details")
fun getCompanyDetails(@PathVariable companyId: Long): ResponseEntity<CompanyDTO> {
val company = companyService.getCompanyByIdOrException(companyId)
return ResponseEntity.ok(company.toDto())
}
After upgrading to Spring-boot 3.0.1 and springdoc-openapi 2.0.2 I see arg0 in swagger ui rather than companyId in the ui

And when trying it out i get 404:
"message": "Failed to convert value of type 'java.lang.String' to required type 'long'; For input string: \"{companyId}\"",
"path": "/api/evans-admin/companies/%7BcompanyId%7D/scheme-admins"
as you can see rather than using given value %7BcompanyId%7D string is being used
I'm seeing the same issue, for both PathVariable and RequestParam.
This actually looks like an issue with Spring Framework itself. I'm seeing arg0, etc. in Spring logs (i.e. https://github.com/spring-projects/spring-framework/issues/29776). Using the -parameters compiler flag fixed the problem.
It seems that the -parameters option does not solve this problem in Gradle.
- Environment:
Spring boot: 3.0.0,springdoc-openapi (starter webmvc ui): 2.0.2
I set build.gradle as follows.
plugins {
id 'org.springframework.boot' version '3.0.0'
id 'io.spring.dependency-management' version '1.1.0'
id 'java'
}
...
tasks.withType(JavaCompile) {
options.compilerArgs.add("-parameters")
}
Instead, the easy way to solve this problem is to clearly define the value (or name) of the @PathVariable annotation.
@Operation(summary = "Get company details", description = "Get company details")
fun getCompanyDetails(@PathVariable(value = "companyId") companyId: Long): ResponseEntity<CompanyDTO> {
val company = companyService.getCompanyByIdOrException(companyId)
return ResponseEntity.ok(company.toDto())
}
In my application, there was the same issue when MutlipartFile was received as @RequestParam, and in this case, it was solved by clearly writing annoation value (or name).
There seems to be a problem that the current library cannot read this value.
I guess this is the same issue as https://github.com/springdoc/springdoc-openapi/issues/2036
@matios13,
You might need to use -parameters.
I am adding an enhancement.
Please do not hesitate to share if this fixes the issue.
Can you 🙏 release a new version with this fix? Can you specify details of You might need to use -parameters? This worked correctly until now with no -parameters field.
@knyttl,
The release would be at the latest, by the end of this month. You can already do your tests with the latest SNAPSHOT.
The explanation of the might need to use -parameters, is related to the deprecation of LocalVariableTableParameterNameDiscoverer with spring-boot 3:
- https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java
And in the new Default implementation is now:
- https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/core/DefaultParameterNameDiscoverer.java
Hi, would you be able to release earlier? The sonatype snapshot repo is down today (returns 504) and we cannot build at all :/
@bnasslahsen
In latest version it is still required to use -parameters compiler flag for proper mapping. It is also mentioned in docs.
Is this correct behavior?