Describe the bug
If the schema contains more than one record type fields of the same type, the generated field's type in the dataclass does not inherit the class' pascal case but instead uses the type defined in the schema.
To Reproduce
from dataclasses_avroschema import ModelGenerator
model_generator = ModelGenerator()
schema = {
'type': 'record',
'doc': 'The 3D bounding box labels of this object.',
'name': 'prism',
'fields': [
{'doc': 'the pose for this object.',
'name': 'pose',
'type': {
'type': 'record',
'doc': 'Represents a transformation from one frame to another as a translation vector and a rotation quaternion.',
'name': 'pose',
'fields': [{
'name': 'pose_name',
'type': 'string'
}]
}
},
{
'doc': 'The object’s Pose in Chassis Frame',
'name': 'object_to_chassis',
'type': 'pose'
}
]
}
result = model_generator.render(schema=schema)
# save the result in a file
with open("models.py", mode="+w") as f:
f.write(result)
Generated model
from dataclasses_avroschema import AvroModel
import dataclasses
@dataclasses.dataclass
class Pose(AvroModel):
"""
Represents a transformation from one frame to another as a translation vector and a rotation quaternion.
"""
pose_name: str
@dataclasses.dataclass
class Prism(AvroModel):
"""
The 3D bounding box labels of this object.
"""
pose: Pose = dataclasses.field(metadata={'doc': 'the pose for this object in cruiseframe.'})
object_to_chassis: pose = dataclasses.field(metadata={'doc': 'The object’s Pose in Chassis Frame'})
Expected behavior
Expected the type of the field to match the generated class name of the Avro record
from dataclasses_avroschema import AvroModel
import dataclasses
@dataclasses.dataclass
class Pose(AvroModel):
"""
Represents a transformation from one frame to another as a translation vector and a rotation quaternion.
"""
pose_name: str
@dataclasses.dataclass
class Prism(AvroModel):
"""
The 3D bounding box labels of this object.
"""
pose: Pose = dataclasses.field(metadata={'doc': 'the pose for this object in cruiseframe.'})
object_to_chassis: Pose = dataclasses.field(metadata={'doc': 'The object’s Pose in Chassis Frame'})
Describe the bug If the schema contains more than one record type fields of the same type, the generated field's type in the dataclass does not inherit the class' pascal case but instead uses the type defined in the schema.
To Reproduce
Generated model
Expected behavior Expected the type of the field to match the generated class name of the Avro record