Victor Silva
Victor Silva

Reputation: 61

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

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"
        },
    ]
}

Upvotes: 6

Views: 873

Answers (1)

Kai Thoma
Kai Thoma

Reputation: 572

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

Upvotes: 0

Related Questions