You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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())
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: