Fix(classgen): support number conversion from jsonschema

This commit is contained in:
Johannes Kirschbauer
2025-03-25 19:27:01 +01:00
parent d5c0a2eb9c
commit 679387e4ba

View File

@@ -34,6 +34,10 @@ def map_json_type(
return {"int"} return {"int"}
if json_type == "boolean": if json_type == "boolean":
return {"bool"} return {"bool"}
# In Python, "number" is analogous to the float type.
# https://json-schema.org/understanding-json-schema/reference/numeric#number
if json_type == "number":
return {"float"}
if json_type == "array": if json_type == "array":
assert nested_types, f"Array type not found for {parent}" assert nested_types, f"Array type not found for {parent}"
return {f"""list[{" | ".join(nested_types)}]"""} return {f"""list[{" | ".join(nested_types)}]"""}