You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Hi there. I faced a problem with generating OpenAPI specification using Kotlin.
I have a parameter in the RestController's method annotated with ParameterObject. The type of this parameter is a Kotlin class with companion object which have a non-const members (fields and/or properties). In my case it has read-only property of type java.time.Duration. When I'm accessing an OpenAPI specification via /v3/api-docs endpoint I'm getting a StackOverflowError at line MethodParameterPojoExtractor:113.
Annotating this property with a JvmField annotation nor JvmStatic didn't help.
I did some debug and realized that the MethodParameterPojoExtractor#extractFrom method is falling into recursion with the Duration.ZERO field which is static too.
To Reproduce
I'm using:
Spring 5.2.4.RELEASE
Spring Boot 2.2.5.RELEASE
SpringDoc OpenAPI 1.5.6
Kotlin 1.4.31
There is an example controller with which it can be reproduced:
@Tag(name = "Some API")
@RestController
@RequestMapping("/example")
class ExampleController {
@GetMapping(produces = [MediaType.TEXT_PLAIN])
@Operation(summary = "My awesome operation")
fun test(@ParameterObject request: TestRequest): ResponseEntity<String> {
return ResponseEntity.ok("test")
}
}
class TestRequest(
@field:Parameter(description = "Some parameter")
val param: String
) {
companion object {
val SOME_CONSTANT_DURATION = Duration.ofHours(1L)
}
}
So if you try to access http://localhost:8080/v3/api-docs you will receive HTTP status code 500 and StackOverflowError stack trace in the logs.
Expected behavior
So I think it should be allowed to use such classes as a parameter annotated with ParameterObject.
Maybe it's not needed to collect static fields in the MethodParameterPojoExtractor#allFieldsOf method.
The text was updated successfully, but these errors were encountered:
Describe the bug
Hi there. I faced a problem with generating OpenAPI specification using Kotlin.
I have a parameter in the RestController's method annotated with
ParameterObject
. The type of this parameter is a Kotlin class with companion object which have a non-const members (fields and/or properties). In my case it has read-only property of typejava.time.Duration
. When I'm accessing an OpenAPI specification via/v3/api-docs
endpoint I'm getting a StackOverflowError at lineMethodParameterPojoExtractor:113
.Annotating this property with a
JvmField
annotation norJvmStatic
didn't help.I did some debug and realized that the
MethodParameterPojoExtractor#extractFrom
method is falling into recursion with theDuration.ZERO
field which is static too.To Reproduce
I'm using:
Spring 5.2.4.RELEASE
Spring Boot 2.2.5.RELEASE
SpringDoc OpenAPI 1.5.6
Kotlin 1.4.31
There is an example controller with which it can be reproduced:
So if you try to access
http://localhost:8080/v3/api-docs
you will receive HTTP status code 500 and StackOverflowError stack trace in the logs.Expected behavior
So I think it should be allowed to use such classes as a parameter annotated with
ParameterObject
.Maybe it's not needed to collect static fields in the
MethodParameterPojoExtractor#allFieldsOf
method.The text was updated successfully, but these errors were encountered: