How to compile avro schema from an avsc that contains references using avrogen?
Asked Answered
T

1

6

I have these two avsc files, the first makes a reference to the second but when trying to compile using avrogen an error is returned and the schema is not generated.

Error:

Exception occurred. Undefined name: AnalogProperty at 'fields[0].type.items.fields[2].type.fields[0].type'

avsc 1

"doc": "Measurement Type, Analog or Discrete",
"name": "AnalogProperties",
"type": {
   "fields": [
     {
       "doc": "",
       "name": "RealPower",
       "type": "AnalogProperty"
     }
}

avsc 2

{
    "name": "AnalogProperty",
    "namespace": "Kafka.AvroSchemas",
    "doc": "AnalogProperty object",
    "type": "record",
    "fields": [{
            "doc": "Circuit from requested topology.",
            "name": "cValue",
            "type": "double"
        },
        {
            "doc": "Circuit from requested topology.",
            "name": "cTimestamp",
            "type": "string"
        },
    ]
}
Tudela answered 16/9, 2021 at 15:4 Comment(0)
U
0

This is not possible with the current version of avrogen. But someone forked it and created avrogenms, which does exactly what you're asking for:

allow reference to types on external schema file

See github project: https://github.com/Meffistas/avro-ms

Us answered 3/6 at 13:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.