Skip to content

does not support avro union, i.e., .avsc file is a JSON array? #20

@300LiterPropofol

Description

@300LiterPropofol

Hello,

I am doing in command line

avro_validator union_schema.avsc producing_message.json

My <union_schema.avsc> is a JSON array, with different dependent objects inside. I can give an example below.

[
{
    "type": "record",
    "namespace": "com.company.model",
    "name": "AddressRecord",
    "fields": [
        {
            "name": "streetaddress",
            "type": "string"
        },
        {
            "name": "city",
            "type": "string"
        }
    ]
},
{
    "namespace": "com.company.model",
    "type": "record",
    "name": "person",
    "fields": [
        {
            "name": "firstname",
            "type": "string"
        },
        {
            "name": "lastname",
            "type": "string"
        },
        {
            "name": "address",
            "type": {
                "type": "array",
                "items": "com.company.model.AddressRecord"
            }
        }
    ]
}
]

When I was trying to validate through command line, I got an error

Traceback (most recent call last):
  File "/.local/bin/avro_validator", line 8, in <module>
    sys.exit(main())
  File "/.local/lib/python3.6/site-packages/avro_validator/cli.py", line 28, in main
    parsed_schema = schema.parse()
  File "/.local/lib/python3.6/site-packages/avro_validator/schema.py", line 28, in parse
    return RecordType.build(schema)
  File "/.local/lib/python3.6/site-packages/avro_validator/avro_types.py", line 647, in build
    cls._validate_json_repr(json_repr)
  File "/.local/lib/python3.6/site-packages/avro_validator/avro_types.py", line 63, in _validate_json_repr
    if cls.required_attributes.intersection(json_repr.keys()) != cls.required_attributes:
AttributeError: 'list' object has no attribute 'keys'

I couldn't find info in README in this repo about avro union. What should I do to make this work? Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions