0.1.2 • Published 5 years ago

avro-stitch v0.1.2

Weekly downloads
27
License
MIT
Repository
github
Last release
5 years ago

avro-stitch

oclif Version Downloads/week License

Avro supports the abilities to reference other schemas, but confluent's schema registry doesn't allow you to reference one schema from another. To better support this use case, this tool will take a directory of .avsc files, each with a single record type in them, and a root entity, and will output one .avsc with everything in it. Avro has specific rules about defining a record type before using it, and this tool will ensure that those rules are respected.

Usage

Imagine the following:

a.avsc:

{
    "name": "A",
    "type": "record",
    "fields": [
        {
            "name": "b",
            "type": "B"
        }
    ]
}

b.avsc

{
    "name": "B",
    "type": "record",
    "fields": [
        {
            "name": "a",
            "type": "A"
        }
    ]
}

If you ran avro-stitch this way:

$ avro-stitch -d ~/dev/schemas -r A -o target.avsc

You'd get this output:

target.avsc

{
    "name": "A",
    "type": "record",
    "fields": [
        {
            "name": "b",
            "type": {
              "name": "B",
              "type": "record",
              "fields": [
                  {
                      "name": "a",
                      "type": "A"
                  }
              ]
          }
        }
    ]
}

target.avsc should be usable in confluent's schema registry.

Commands