Thanks for reply.
Sadly it does not work that way (here). Even:
{
"name" : "ARecord",
"type" : "record",
"namespace" : "A",
"fields" : [
{"name": "id", "type": "string" },
{
"name": "B",
"type": {
"type": "record",
"name": "BRecord",
"fields": [
{
"name": "C",
"type": "string"
}
]
}
}
]
}
does not require C. And that's not what I want ... I'd like optional B, and
once user provide B, then B.C is required.
Martin.
2017-11-27 15:06 GMT+01:00 Dan Schmitt <[email protected]>:
> "name": "B",
> "type": ["null", {
>
> The [] union lets you do null or a BRecord, your JSON does null.
> Pull the null from the union and it will require the C.
>
> On Mon, Nov 27, 2017 at 9:00 AM, Martin Mucha <[email protected]> wrote:
> > Hi,
> >
> > I have this avro schema:
> >
> > {
> > "name" : "ARecord",
> > "type" : "record",
> > "namespace" : "A",
> > "fields" : [
> > {"name": "id", "type": "string" },
> > {
> > "name": "B",
> > "type": ["null", {
> > "type": "record",
> > "name": "BRecord",
> > "fields": [
> > {
> > "name": "C",
> > "type": "string"
> > }
> > ]
> > }]
> > }
> > ]
> > }
> >
> >
> > and following JSON, which validates against it:
> >
> > {
> > "id": "...",
> > "B": {
> >
> > }
> > }
> >
> >
> > I would expect, that C is required. Why it's not? What shall I do to
> make it
> > required?
> >
> > Thanks!
> > Martin.
>