bencebalogh / avro-schema-registry

Confluent Schema Registry implementation in javascript to easily serialize and deserialize kafka messages
MIT License
28 stars 30 forks source link

Can't create a schema with array field #34

Closed joaop132 closed 4 years ago

joaop132 commented 4 years ago

Hi,

I'm trying to create an avro schema and one of my fields need's to be a list of strings, but when i run my code it gives me a error of undefined type. I tried to debug a little of your code and from what've seen looks like it's going the wrong flow. Can you help me?

Here is the schema I'm trying to build { "type": "record", "name": "Test", "namespace": "my.topic", "fields": [ { "name": "name", "type": "string" }, { "name": "date", "type": "string" }, { "name": "fields", "type": "array", "items": "string" } ] }

Thank you.

bencebalogh commented 4 years ago

Hi You should define the array type like this in the schema:

{
    "type": "record",
    "name": "Test",
    "namespace": "my.topic",
    "fields": [
        {
            "name": "name",
            "type": "string"
        },
        {
            "name": "date",
            "type": "string"
        },
        {
            "name": "fields",
            "type": {
                "type": "array",
                "items": "string"
            }
        }
    ]
}

Let me know if there's anything else I can help with, closing this for now.