Describe the bug
When working with enum type whose values are objects, the field names of the objects are not populated correctly.
It generates something like: array___title____usa____type____object____properties_____usa_____title____usa____type____object____properties________required________additional_properties___false_____additional_properties___false_
To Reproduce
Generated Python Location class
class Location(Enum):
array___title____usa____type____object____properties_____usa_____title____usa____type____object____properties________required________additional_properties___false_____additional_properties___false_ = {
'title': 'USA',
'type': 'object',
'properties': {
'USA': {
'title': 'USA',
'type': 'object',
'properties': {},
'required': [],
'additionalProperties': False,
}
},
'additionalProperties': False,
}
array___title____canada____type____object____properties_____canada_____title____canada____type____object____properties________required________additional_properties___false_____additional_properties___false_ = {
'title': 'CANADA',
'type': 'object',
'properties': {
'Canada': {
'title': 'Canada',
'type': 'object',
'properties': {},
'required': [],
'additionalProperties': False,
}
},
'additionalProperties': False,
}
Example schema:
{
"title": "FruitVocab",
"type": "object",
"properties": {
"Vocab": {
"type": "object",
"properties": {
"Fruits": {
"title": "Fruits",
"type": "object",
"properties": {
"Location": {
"title": "Location",
"type": "array",
"enum": [
{
"title": "USA",
"type": "object",
"properties": {
"USA": {
"title": "USA",
"type": "object",
"properties": {},
"required": [],
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"title": "CANADA",
"type": "object",
"properties": {
"Canada": {
"title": "Canada",
"type": "object",
"properties": {},
"required": [],
"additionalProperties": false
}
},
"additionalProperties": false
}
]
}
},
"required": [],
"additionalProperties": false
}
},
"required": []
}
},
"additionalProperties": false,
"required": []
}
Used commandline:
$ datamodel-codegen --use-standard-collections --use-unique-items-as-set --collapse-root-models --use-annotated --use-title-as-name --use-subclass-enum --disable-appending-item-suffix --input-file-type jsonschema --input errorJsonSchema.json --output errorMain.py --output-model-type pydantic_v2.BaseModel --allow-population-by-field-name --snake-case-field
Expected behavior
Needs to have members name which corresponds to their title.
Version:
Additional context
Add any other context about the problem here.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too