julianpeeters / avrohugger

Generate Scala case class definitions from Avro schemas
Apache License 2.0
201 stars 120 forks source link

Generator from IDL doesn't support multiple namespaces #158

Open AlgMi opened 2 years ago

AlgMi commented 2 years ago

Generating scala code from .avdl doesn't create case classes for fields that have different namespace than the protocol. 1.0.0 and older versions are affected

Example: Only class for Simple record will be created skipping the Constraint enum

@namespace("system.test")
protocol Simple {
    record Simple {
        union { null, int } id = null;
        system.abc.Constraint constraints;
    }
    @namespace("system.abc")
    enum Constraint {
        create, delete
    }
}

Example: Generating from .avsc generates both Simple and Constraint correctly.

{
  "type" : "record",
  "name" : "Simple",
  "namespace" : "system.test",
  "fields" : [ {
    "name" : "id",
    "type" : [ "null", "int" ],
    "default" : null
  }, {
    "name" : "constraints",
    "type" : {
      "type" : "enum",
      "name" : "Constraint",
      "namespace" : "system.abc",
      "symbols" : [ "create", "delete" ]
    }
  } ]
}