json-schema-codegen
json-schema-codegen copied to clipboard
KeyError: Property's type is not inferred when it references a definition
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Table",
"definitions": {
"dataSource": {
"properties": {
"type": {
"type": "string",
"enum": [
"postgres",
"script"
],
"default": "postgres"
}
},
"type": "object"
}
},
"properties": {
"datasource": {
"$ref": "#/definitions/dataSource"
}
}
}
fails with
Exception has occurred: KeyError 'type' File "*****/json_codegen/generators/python3.py", line 252, in get_partial_annotation_from_definition property_type = property_["type"]
It doesn't fail if we specify the type
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Table",
"definitions": {
"dataSource": {...}
},
"properties": {
"datasource": {
"$ref": "#/definitions/dataSource",
"type": "object"
}
}
}