From 38ca3b29b51401c1d443c4ef83886598612b233a Mon Sep 17 00:00:00 2001 From: LeePui <444561897@qq.com> Date: Tue, 16 Apr 2024 19:54:17 +0800 Subject: [PATCH] add support for swagger object type (#3426) Co-authored-by: lipeikui --- api/core/tools/tool/api_tool.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/core/tools/tool/api_tool.py b/api/core/tools/tool/api_tool.py index 4037ef627c482e..f7b963a92e8865 100644 --- a/api/core/tools/tool/api_tool.py +++ b/api/core/tools/tool/api_tool.py @@ -291,6 +291,16 @@ def _convert_body_property_type(self, property: dict[str, Any], value: Any) -> A 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):