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
data class DifficultClass(
val name: String,
/**
* properties can be anything mapping a string to Any
*/
@Schema(example = """
{"sequence": 123}
""")
val properties: Map<String, Any> = emptyMap()
)
@RestController
@RequestMapping("/")
// the below register is a fix for swagger ui for native image. We could not find out the reason,
// but the class will cause a "Type not found" and leave the swagger screen in a half-ready state.
//@RegisterReflectionForBinding(java.lang.invoke.MethodHandles.Lookup::class)
class DifficultController {
@PostMapping("a")
@Operation(summary = "reproduce the problem")
fun someFunction(@RequestBody problems: List<DifficultClass>) : DifficultClass? {
return if (problems.isEmpty())
null
else
problems.first()
}
}
The workaround is to register the java class for reflection as follows @RegisterReflectionForBinding(java.lang.invoke.MethodHandles.Lookup::class)
Expected behavior
The swagger should come up with a field for the request body the one controller method /a (which it does in non-native mode)
No exception should be thrown
Screenshots
This is the screen that comes up in the case of native image without the reflection hint
Additional context: Workaround
The workaround, see above, is to register java.lang.invoke.MethodHandles.Lookup for the native image, but we don't know what is the underlying reason. I suspect it should be added to the springdoc provided spring-configuration-meadata.json in springdoc-openapi-starter-common-2.8.5.jar.
The text was updated successfully, but these errors were encountered:
/v3/api-docs fails at runtime in native mode, omitting the entity, when a http entity with a Map is used
/swagger-ui/index.html, or, better say /v3/api-docs generates an incomplete open-api definition due to an exception.
I am using Spring boot 3.4.3 and springdoc 2.8.5.
To Reproduce
The entity:
DifficultClass.kt.txt
The controller:
DifficultController.kt.txt
Resulting exception (only native)
nativeException.txt
Here is a project including test to reproduce:
swaggerNativeBugDemo.zip
use
./gradlew nativeTest
to reproduce.
The workaround is to register the java class for reflection as follows
@RegisterReflectionForBinding(java.lang.invoke.MethodHandles.Lookup::class)
Expected behavior
Screenshots

This is the screen that comes up in the case of native image without the reflection hint
Additional context: Workaround
The workaround, see above, is to register java.lang.invoke.MethodHandles.Lookup for the native image, but we don't know what is the underlying reason. I suspect it should be added to the springdoc provided spring-configuration-meadata.json in springdoc-openapi-starter-common-2.8.5.jar.
The text was updated successfully, but these errors were encountered: