typing.List[AvroModel] works but typing.Dict[str, AvroModel] seems to fail #184
Closed
Description
Describe the bug
Should dictionary representations be deserializable when using "avro-json" I find a case where "avro" works but "avro-json" does not (ps. cool repo!).
To Reproduce
Take your original Address+User examples and changing typing.List -> typing.Dict[str,Address]
import typing
import dataclasses
from dataclasses_avroschema import AvroModel
@dataclasses.dataclass
class Address(AvroModel):
"An Address"
street: str
street_number: int
@dataclasses.dataclass
class User(AvroModel):
"User with multiple Address"
name: str
age: int
addresses: typing.Dict[str, Address]
user = User.fake()
# Fails with error "ValueError: no value and no default" raised from generator fastavro.json_reader(input_stream, schema)
serialization_type = 'avro-json'
s = user.serialize(serialization_type=serialization_type)
User.deserialize(s, serialization_type=serialization_type)
Expected behavior
The same output as with the "avro" serialization type (as below) - just wanted to report this and confirm that this is the expected behaviour?
# Works fine
serialization_type = 'avro'
s = user.serialize(serialization_type=serialization_type)
User.deserialize(s, serialization_type=serialization_type)
python: 3.7.8
dataclasses-avroschema==0.30.0
fastavro==1.5.2
Metadata
Assignees
Labels
No labels