Describe the bug
Importing a schema and partial overwrite it (e.g., set a different default value) leads to lost type information
To Reproduce
schemaA
{
"type": "object",
"title": "SchemaA",
"properties": {
"test": {
"title": "test",
"type": "string",
"default": "default_value1"
}
}
}
schemaB.json
{
"allOf": [
{
"$ref": "SchemaA.json"
}
],
"type": "object",
"title": "SchemaB",
"properties": {
"test": {
"default": "default_value2"
}
}
}
Used commandline:
$ datamodel-codegen --input schemaB.json --output model.py
Result model.py: type of test
in SchemaB is resetted to Any
class SchemaA(BaseModel):
test: Optional[str] = Field('default_value1', title='test')
class SchemaB(SchemaA):
test: Optional[Any] = 'default_value2'
Expected behavior
type of test
in SchemaB is still str
class SchemaA(BaseModel):
test: Optional[str] = Field('default_value1', title='test')
class SchemaB(SchemaA):
test: Optional[str] = 'default_value2'
Version:
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