Open Masqueey opened 1 week ago
Both classes are called in the same way, should it not be something like
class MessageHeader(AvroBaseModel):
version: str
MessageType: str
class Message(AvroBaseModel):
MessageHeader: typing.Optional[typing.List[MessageHeader]]
MessageBody: str
Describe the bug A schema with a field name that is identical to a class name will fail to be parsed by Pydantic (and also create the wrong
fake()
data) when it is within a type definition (e.g. astyping.List[ExampleType]
).To Reproduce
AvroBaseModel
fromdataclasses_avroschema.pydantic
.As an example:
.fake()
on the model. It will generate eitherNone
or[None]
To Bypass
_
To bypass the error in the above example:
Expected behavior Have the model be usable in the same way when not using any typing specifications like optional or list without changing the name or having to add metadata to the model.