jackson-dataformats-binary
jackson-dataformats-binary copied to clipboard
Cannot find method to generate AVRO schema will nullable Map values
This class when Avro'd
public final class Foo {
private Map<String, String> strings;
public Map<String, String> getStrings() {
return strings;
}
public void setStrings( Map<String, String> strings ) {
this.strings = strings;
}
Results in this schema:
{
"type" : "record",
"name" : "Foo",
"namespace" : "my.package",
"doc" : "Schema for my.package",
"fields" : [ {
"name" : "strings",
"type" : [ "null", {
"type" : "map",
"values" : "string"
} ]
}
Where as I want this schema:
{
"type" : "record",
"name" : "Foo",
"namespace" : "my.package",
"doc" : "Schema for my.package",
"fields" : [ {
"name" : "strings",
"type" : [ "null", {
"type" : "map",
"values" : [ "null", "string" ]
} ]
}
I can't see a way to do this currently.
I've gone with programmatically editing the result schema to make the map values nullable as a workaround for now.
@DominicDeCesare-Capita please include a reproduction of what you are doing, how: unfortunately description is bit unclear on what exactly is happening.
Actually I think description is ok. So basically String
values here should be indicated to be "optional" (String OR null), not mandatory.