add support for swagger object type (#3426)

Co-authored-by: lipeikui <lipeikui@3vjia.com>
This commit is contained in:
LeePui 2024-04-16 19:54:17 +08:00 committed by GitHub
parent 066076b157
commit 38ca3b29b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -291,6 +291,16 @@ class ApiTool(Tool):
elif property['type'] == 'null':
if value is None:
return None
elif property['type'] == 'object':
if isinstance(value, str):
try:
return json.loads(value)
except ValueError:
return value
elif isinstance(value, dict):
return value
else:
return value
else:
raise ValueError(f"Invalid type {property['type']} for property {property}")
elif 'anyOf' in property and isinstance(property['anyOf'], list):