Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.
Given below schema, where enum field type is some.CustomEnum
{
"title": "Test",
"description": "Test 123",
"type": "object",
"properties": {
"enum": {
"title": "Enum",
"default": "one",
"type": "some.CustomEnum"
}
}
}
I would like code generator to give below
...
class Test(BaseModel):
enum: some.CustomEnum = Field('one', title='Enum')
At the moment instead of some.CustomEnum it is giving Any.
Note some.CustomEnum would not type check correctly with the one generated by code gen even though they have the same values.
This is because I already have the python code for some.CustomEnum and do not need the code to be generated again.
Describe the solution you'd like
A clear and concise description of what you want to happen.
This is to handle cases where I already have some of the models and I just want the typing next to the field name in the code generation.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
One solution is to manually parse the output of the current code gen and remove the enum class and also update the enum type. This is tedious as one would have to define patterns for when class starts and ends.
Another solution is to have a new section in the schema that has information about these fields and somehow add it to the generated class but then the Field information would not be available.
I actually thought enum_field_as_literal="all" flag would convert all enums to literal[...], which would help but it didn't seem to do anything.
Additional context
Add any other context or screenshots about the feature request 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