compendium icon indicating copy to clipboard operation
compendium copied to clipboard

Correct AVRO (.avpr) format

Open angoglez opened this issue 5 years ago • 1 comments

Description

It seems the .avpr accepted by compendium it's different from the .avpr "official" format.

EXAMPLE: .avpr accepted currently by compendium (when storing a schema) (from compendium-example repo)

{
  "type": "record",
  "name": "Supplier",
  "namespace": "higherkindness.compendiumtest",
  "fields": [
    {
        "name": "id_supplier",
        "type": "string"
    }, 
    {
        "name": "name",
        "type": "string"
    },
    {
        "name": "email",
        "type": "string"
    },
    {
        "name": "phone",
        "type": "string"
    }  ]
}

➡️ The .avpr accepted by the plugin sbt-mu-srcgen (that we are now using mixed with the old sbt-compendium) says to accept another format which is more similar to the one written in the AVRO documentation. This format is not recognized by compendium when trying to store a schema.

EXAMPLE: .avpr accepted by sbt-mu-srcgen (from mu-scala docs)

{
  "namespace" : "foo",
  "protocol" : "AvroGreeter",
  "types" : [
    {
      "name" : "HelloRequest",
      "type" : "record",
      "fields" : [
        {
          "name" : "arg1",
          "type" : "string"
        },
        {
          "name" : "arg2",
          "type" : [
            "null",
            "string"
          ]
        },
        {
          "name" : "arg3",
          "type" : {
            "type" : "array",
            "items" : "string"
          }
        }
      ]
    },
    {
      "name" : "HelloResponse",
      "type" : "record",
      "fields" : [
        {
          "name" : "arg1",
          "type" : "string"
        },
        {
          "name" : "arg2",
          "type" : [
            "null",
            "string"
          ]
        },
        {
          "name" : "arg3",
          "type" : {
            "type" : "array",
            "items" : "string"
          }
        }
      ]
    }
  ],
  "messages" : {
    "sayHelloAvro" : {
      "request" : [
        {
          "name" : "arg",
          "type" : "HelloRequest"
        }
      ],
      "response" : "HelloResponse"
    }
  }
}

🔗 RELATED DOCUMENT: AVRO PROTOCOL (.avpr) COMPENDIUM/SBT-MU-SRCGEN MISMATCH

angoglez avatar Jun 29 '20 17:06 angoglez

@angoglez I found the problem. The first protocol (the one that mu accepts) includes the types and the services. Inside the types you provide an array of schemas where each one is the type of message accepted by compendium.

So my question is, is this the expected behaviour? I think so, since compendium is for storing types and not the protocol as a whole (types and services).

fedefernandez avatar Jul 01 '20 18:07 fedefernandez