Closed
Description
As title. I'm working on an API in Spring Boot 2.7.17, using springdoc 1.8.0. It seems like I am forced to effectively duplicate my schema specification between @Schema
and @JsonTypeInfo
, which leaves a sour taste.
@Schema(
subTypes = {
Foo1.class,
Foo2.class,
},
discriminatorProperty = "fooType",
discriminatorMapping = {
@DiscriminatorMapping(value = "foo1", schema = Foo1.class),
@DiscriminatorMapping(value = "foo2", schema = Foo2.class),
})
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
visible = true,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
property = "fooType")
@JsonSubTypes({
@Type(value = Foo1.class, name = "foo1"),
@Type(value = Foo2.class, name = "foo2"),
})
public interface AbstractFoo {
String getFooType();
}
As is evident, the information on the @Schema
annotation exactly matches (and therefore must be kept in sync with) the Jackson type information on JsonTypeInfo
and JsonSubTypes
. Is there a way to get springdoc to build subschema 'routing' documentation without reiterating myself here?