add support for numeric generic keys

pull/148/head
Tim Vahlbrock 2 years ago
parent f4c5404b7f
commit 337a3de33d
No known key found for this signature in database

@ -127,6 +127,14 @@ def value_to_schema(value):
return {"type": "array", "items": value_to_schema(value[0])}
# check if value is a dict
elif isinstance(value, dict):
all_keys_are_generic = all(
isinstance(key, str) and key.isnumeric() for key in value
)
if all_keys_are_generic:
return {
"type": "object",
"additionalProperties": value_to_schema(list(value.values())[0]),
}
return {
"type": "object",
"properties": {key: value_to_schema(value[key]) for key in value},

Loading…
Cancel
Save