fix(swagger): improve non-nullable property handling in Swagger JSON

- Updated set_non_nullable function to ensure required properties are processed correctly.
- Added logic to handle cases where 'required' is not present, maintaining existing functionality for non-nullable properties.
This commit is contained in:
yusing
2025-09-14 00:12:35 +08:00
parent 7b028adaa9
commit e359bc8fd9

View File

@@ -17,8 +17,13 @@ def set_non_nullable(data):
if "type" not in data:
return
if data["type"] == "object" and "properties" in data:
for v in data["properties"].values():
set_non_nullable(v)
if "required" in data:
for k, v in data["properties"].items():
if k in data["required"]:
set_non_nullable(v)
else:
for v in data["properties"].values():
set_non_nullable(v)
if data["type"] == "array":
for v in data["items"]:
set_non_nullable(v)