from dataclasses_avroschema import ModelGenerator, ModelType
schema = {
"type": "enum",
"name": "Color",
"symbols": [
"red",
"blue"
]
} # this is actually loaded from the AVSC file. Pasting the dict for simplicity.
model_generator = ModelGenerator()
python_class = model_generator.render(schema=schema, model_type=ModelType.DATACLASS.value)
with the error:
File "<location>/.venv/lib/python3.9/site-packages/dataclasses_avroschema/model_generator/generator.py", line 67, in render
return self.render_module(
File "<location>/.venv/lib/python3.9/site-packages/dataclasses_avroschema/model_generator/generator.py", line 97, in render_module
return model_generator.render(schemas=schemas)
File "<location>/.venv/lib/python3.9/site-packages/dataclasses_avroschema/model_generator/lang/python/base.py", line 66, in render
classes = "\n".join(self.render_class(schema=schema) for schema in schemas)
File "<location>/.venv/lib/python3.9/site-packages/dataclasses_avroschema/model_generator/lang/python/base.py", line 66, in <genexpr>
classes = "\n".join(self.render_class(schema=schema) for schema in schemas)
File "<location>/.venv/lib/python3.9/site-packages/dataclasses_avroschema/model_generator/lang/python/base.py", line 143, in render_class
record_fields: typing.List[JsonDict] = schema["fields"]
KeyError: 'fields'
Describe the solution you'd like
It would be great to support all valid AVRO schemas to be supported and converted to python classes, also when fields is missing
Describe alternatives you've considered
Additional context
Add any other context or screenshots about the feature request here.
Is your feature request related to a problem? Please describe. I have a valid AVRO schema which I am unable to translate into a Python class. Example:
running the following fails:
with the error:
Describe the solution you'd like It would be great to support all valid AVRO schemas to be supported and converted to python classes, also when
fields
is missingDescribe alternatives you've considered
Additional context Add any other context or screenshots about the feature request here.