when I have a polymorphic class and add @JsonSchemaDescription at the visible type property, the description is ignored and not put in the Schema.
While generating the schema, I see this log (thanks for that, guess it saved some hours of research):
WARN com.kjetland.jackson.jsonSchema.JsonSchemaGenerator - Ignoring property 'type' in [simple type, class java.lang.String] since it has already been added, probably as type-property using polymorphism
Here is a simple example to reproduce:
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
property = "type",
include = JsonTypeInfo.As.EXISTING_PROPERTY,
visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = SomeSuperclass.SomeSubType.class, name = "some"),
@JsonSubTypes.Type(value = SomeSuperclass.SomeOtherSubType.class, name = "other")
})
public class SomeSuperclass {
@JsonSchemaDescription("Defines the type.")
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static class SomeSubType extends SomeSuperclass {}
public static class SomeOtherSubType extends SomeSuperclass {}
}
So my description is missing. I als tried to merge the description in the property spec with different variants of @JsonSchemaInject and @JsonSchemaString at the property, the super class and the sub classes. None of my variants did the trick.
Is there any workaround to add a description to a type property that is used with @JsonTypeInfo?
Hi,
when I have a polymorphic class and add
@JsonSchemaDescription
at the visible type property, the description is ignored and not put in the Schema.While generating the schema, I see this log (thanks for that, guess it saved some hours of research):
Here is a simple example to reproduce:
I get JSON Schema for the two subtypes like this:
So my description is missing. I als tried to merge the description in the property spec with different variants of
@JsonSchemaInject
and@JsonSchemaString
at the property, the super class and the sub classes. None of my variants did the trick.Is there any workaround to add a description to a type property that is used with
@JsonTypeInfo
?Thanks in advance for any ideas that help.
My desired output would be like this: