У меня:
Код: Выделить всё
public class DonationFormResponse {
...
@Schema(
description = "The form layout.",
oneOf = { ClassicFormLayout.class, AdaptiveFormLayout.class }
)
private FormLayout formLayout;
...
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "layout_type")
@JsonSubTypes({
@JsonSubTypes.Type(value = ClassicFormLayout.class),
@JsonSubTypes.Type(value = AdaptiveFormLayout.class)
})
@Schema(description = "The form layout.")
public interface FormLayout {
...
}
@Schema(allOf = FormLayout.class)
public class AdaptiveFormLayout implements FormLayout {
...
}
@Schema(allOf = FormLayout.class)
public class ClassicFormLayout implements FormLayout {
...
}
Код: Выделить всё
"DonationFormResponse" : {
...
"form_layout" : {
"oneOf" : [
{
"$ref" : "#/components/schemas/AdaptiveFormLayout"
},
{
"$ref" : "#/components/schemas/ClassicFormLayout"
}
]
},
...
}
...
"AdaptiveFormLayout" : {
"type" : "object",
"allOf" : [
{
"$ref" : "#/components/schemas/FormLayout"
},
{
"type" : "object",
"properties" : {
"cards" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/Card"
}
}
}
}
]
},
...
"ClassicFormLayout" : {
"type" : "object",
"allOf" : [
{
"$ref" : "#/components/schemas/FormLayout"
}
]
},
п>
Подробнее здесь: https://stackoverflow.com/questions/793 ... -interface
Мобильная версия