API: handle functions with multiple arguments

This commit is contained in:
Johannes Kirschbauer
2024-05-26 18:04:49 +02:00
parent ed171f0264
commit ab656d5655
9 changed files with 85 additions and 24 deletions

View File

@@ -42,10 +42,14 @@ def type_to_dict(t: Any, scope: str = "") -> dict:
return {"type": "array", "items": type_to_dict(t.__args__[0], scope)}
elif issubclass(origin, dict):
return {
"type": "object",
"additionalProperties": type_to_dict(t.__args__[1], scope),
}
value_type = t.__args__[1]
if value_type is Any:
return {"type": "object", "additionalProperties": True}
else:
return {
"type": "object",
"additionalProperties": type_to_dict(value_type, scope),
}
raise BaseException(f"Error api type not yet supported {t!s}")