Closed
Description
public enum Foobar {
@JsonEnumDefaultValue
FOO,
BAR;
}
produces
{
"type" : "enum",
"name" : "Foobar",
"namespace" : "foo",
"symbols" : [ "FOO", "BAR" ]
}
Need it to have the default key value pair in order to make enum forward compatible
{
"type" : "enum",
"name" : "FooBar",
"namespace" : "foo",
"symbols" : [ "FOO", "BAR" ],
"default" : "FOO"
}
Unless I'm missing something I can't find a way to configure the class to fill in the default value when creating the schema
Configured the AvroMapper in some groovy to create the schema for reference
avroMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
.configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true);
avroMapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true)
AvroSchemaGenerator gen = new AvroSchemaGenerator();
gen.enableLogicalTypes();
avroMapper.acceptJsonFormatVisitor(classFile, gen);
AvroSchema schemaWrapper = gen.getGeneratedSchema();
org.apache.avro.Schema avroSchema = schemaWrapper.getAvroSchema();
String avroSchemaInJSON = avroSchema.toString(true);