Describe the bug
The generated code tries to subclass an Enum, which makes python raise TypeError. Seems to be related to the "AllOf" keyword. When the enclosing "AllOf" is removed, the generated code is without Enum-subclassing and it works as expected.
To Reproduce
Example schema:
{
"openapi": "3.0.2",
"components": {
"schemas": {
"ProcessingStatus": {
"title": "ProcessingStatus",
"enum": [
"COMPLETED",
"PENDING",
"FAILED"
],
"type": "string",
"description": "The processing status"
},
"ProcessingTask": {
"title": "ProcessingTask",
"type": "object",
"properties": {
"processing_status": {
"title": "Status of the task",
"allOf": [
{
"$ref": "#/components/schemas/ProcessingStatus"
}
],
"default": "COMPLETED"
}
}
}
}
}
}
Used commandline:
$ datamodel-codegen --input openapi_test.json --output models_test.py
Version:
@agrav
Thank you for creating this issue.
OK, I will fix it.
@agrav
I have released a new version as 0.6.4
This version ignores allOf when it has only an enum object.
@koxudaxi
Thank you, much appreciated.
Most helpful comment
@koxudaxi
Thank you, much appreciated.