Hi everybody,
i am trying to build the followong JSON schema:
[{
"type": "record",
"name": "Author",
"fields": [{
"name": "name",
"type": "string"
},
{
"name": "birthday",
"type": "long"
}]
},
{
"type": "record",
"name": "Book",
"fields": [{
"name": "title",
"type": "string"
},
{
"name": "author",
"type": ["Author", "string"]
}]
}]
In my humble opinion this JSON schema is valid.
But it seems that the SchemaBuilder API does not permit to build this schema.
The corresponding code should be something like that:
Schema schema = SchemaBuilder
.unionOf()
.record("Author")
.fields()
.name("name").type().stringType().noDefault()
.name("birthday").type().longType().noDefault()
.endRecord().and()
.record("Book")
.fields()
.name("title").type().stringType().noDefault()
.name("author").type().unionOf()
.type("Author").and()
.stringType().endUnion()
.noDefault()
.endRecord().endUnion();
But after a call to unionOf() the type(name) method is not available.
Is there any reason for this limitation?
Thank you very much
Tony Imbault