Describe the bug
The casing for an enum field is incorrect and does not create a Pascal cased class name causing model with syntax error when field name and enum names are same
To Reproduce
from dataclasses_avroschema import ModelGenerator
model_generator = ModelGenerator()
schema = {
'type': 'record',
'doc': 'The 3D bounding box labels of this object.',
'name': 'msl_prism',
'fields': [
{'doc': 'Source of the ingested segment, ie. ON_ROAD, SIMULATION, etc.',
'default': 'UNKNOWN',
'name': 'data_source',
'type': {
'default': 'UNKNOWN',
'type': 'enum',
'name': 'data_source',
'symbols': ['SIMULATION', 'ON_ROAD', 'UNKNOWN']
}
}
]
}
result = model_generator.render(schema=schema)
# save the result in a file
with open("models.py", mode="+w") as f:
f.write(result)
Actual
from dataclasses_avroschema import AvroModel
import dataclasses
import enum
class data_source(enum.Enum):
SIMULATION = "SIMULATION"
ON_ROAD = "ON_ROAD"
UNKNOWN = "UNKNOWN"
class Meta:
default = "UNKNOWN"
@dataclasses.dataclass
class MslPrism(AvroModel):
"""
The 3D bounding box labels of this object.
"""
data_source: data_source = dataclasses.field(metadata={'doc': 'Source of the ingested segment, ie. ON_ROAD, SIMULATION, etc.'}, default=data_source.UNKNOWN)
Expected behavior
from dataclasses_avroschema import AvroModel
import dataclasses
import enum
class DataSource(enum.Enum):
SIMULATION = "SIMULATION"
ON_ROAD = "ON_ROAD"
UNKNOWN = "UNKNOWN"
class Meta:
default = "UNKNOWN"
@dataclasses.dataclass
class MslPrism(AvroModel):
"""
The 3D bounding box labels of this object.
"""
data_source: DataSource = dataclasses.field(metadata={'doc': 'Source of the ingested segment, ie. ON_ROAD, SIMULATION, etc.'}, default=DataSource.UNKNOWN)
Describe the bug The casing for an enum field is incorrect and does not create a Pascal cased class name causing model with syntax error when field name and enum names are same
To Reproduce
Actual
Expected behavior