-
Hey all! I have a use case where I need to deserialize Union schemas into their abstract models, but it only works if I reference a record below the current record. For example, I can deserialize the following (backwards-reference): [
{
"name": "RecordA",
"type": "record",
"fields": []
},
{
"name": "RecordB",
"type": "record",
"fields": [
{
"name": "RecordA",
"type": "RecordA"
}
]
}
] But if I change the order of the records so that RecordB tries to reference RecordA when RecordB comes before RecordA, it will not work (forward-reference). [
{
"name": "RecordB",
"type": "record",
"fields": [
{
"name": "RecordA",
"type": "RecordA"
}
]
},
{
"name": "RecordA",
"type": "record",
"fields": []
}
] Can the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The behavior of the schema reader is actually defined by the spec:
So, even though it looks counter-intuitive, the spec-compliant way to express that union would be: [
{
"name": "RecordB",
"type": "record",
"fields": [
{
"name": "RecordA",
"type": {
"name": "RecordA",
"type": "record",
"fields": []
}
}
]
},
"RecordA"
] |
Beta Was this translation helpful? Give feedback.
The behavior of the schema reader is actually defined by the spec:
So, even though it looks counter-intuitive, the spec-compliant way to express that union would be: