-
-
Notifications
You must be signed in to change notification settings - Fork 534
Description
Describe the bug
When I use @JsonSubTypes
and @Schema(oneOf = {...})
on an interface that has at least one implementation, I get an error when loading the SpringDoc UI and expanding the schema definition for the interface. The schema definition for the implementation also shows an allOf
property even though I haven't configured the schema for any of the implementations.
If I remove the @JsonSubTypes
annotation, everything works.
This is similar to #2655.
To Reproduce
I created a simple application:
https://github.com/erbrecht/spring-doc-json-subtypes/tree/master
To reproduce, uncomment the @JsonSubTypes
annotation in
- Spring Boot 3.4.1
- SpringDoc 2.8.3
Expected behavior
I would expect no errors to show up in the spring doc ui.
I would also expect my implementation class NOT to have the allOf
property defined in the swagger definition.
Screenshots
Errors:
"Bad" schema:
"Good" schema:
Additional context
I'm also not seeing a specific class for the implementations in the schema definition. I just see an array index. I do see these defined in previous versions of spring doc, eg 2.6.0. I'm not sure if this is related, but it seemed worth mentioning.
spring doc 2.6.0, no @JsonSubType
annotation:
spring doc 2.6.0, WITH @JsonSubType
annotation:
spring doc 2.8.3, no @JsonSubType
annotations:
spring doc 2.8.3, WITH @JsonSubType
annotations: