Describe the bug
I'm trying to generate Avro Schema for model with Generic Class.
As a result I'm getting following error:
ValueError: Type ~T for field additonal_info is unknown. Please check the valid types at https://marcosschroh.github.io/dataclasses-avroschema/fields_specification/#avro-field-and-python-types-summary
To Reproduce
from typing import TypeVar, Generic
from dataclasses_avroschema import AvroModel
import pydantic
T = TypeVar('T')
@pydantic.dataclasses.dataclass
class UserInfoGeneric(Generic[T], AvroModel):
name: str
age: int
additonal_info: T
@pydantic.dataclasses.dataclass
class EmailInfoGeneric(AvroModel):
email: str
is_verified: bool
@pydantic.dataclasses.dataclass
class UserEmailInfo(UserInfoGeneric[EmailInfoGeneric], AvroModel):
pass
print(UserEmailInfo.fake())
print(UserEmailInfo.avro_schema())
Expected behavior
I'd like to see behaviour similar to example where I'm not using Generic classes.
from typing import TypeVar, Generic
from dataclasses_avroschema import AvroModel
import pydantic
@pydantic.dataclasses.dataclass
class EmailInfo(AvroModel):
email: str
is_verified: bool
@pydantic.dataclasses.dataclass
class AddressInfo(AvroModel):
street: str
city: str
state: str
zip: int
@pydantic.dataclasses.dataclass
class UserInfo(AvroModel):
name: str
age: int
additonal_info: AddressInfo | EmailInfo
print(UserInfo.fake())
print(UserInfo.avro_schema())
Describe the bug
I'm trying to generate Avro Schema for model with Generic Class.
As a result I'm getting following error:
To Reproduce
Expected behavior
I'd like to see behaviour similar to example where I'm not using Generic classes.