소스 검색

fix:To fix the issue of missing reference to body parameter (#15443)

Co-authored-by: crazywoola <427733928@qq.com>
tags/1.0.1
Lick-liu 7 달 전
부모
커밋
41bf8d925f
No account linked to committer's email address
1개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 14
    0
      api/core/tools/custom_tool/tool.py

+ 14
- 0
api/core/tools/custom_tool/tool.py 파일 보기

@@ -179,6 +179,18 @@ class ApiTool(Tool):
for content_type in self.api_bundle.openapi["requestBody"]["content"]:
headers["Content-Type"] = content_type
body_schema = self.api_bundle.openapi["requestBody"]["content"][content_type]["schema"]

# handle ref schema
if "$ref" in body_schema:
ref_path = body_schema["$ref"].split("/")
ref_name = ref_path[-1]
if (
"components" in self.api_bundle.openapi
and "schemas" in self.api_bundle.openapi["components"]
):
if ref_name in self.api_bundle.openapi["components"]["schemas"]:
body_schema = self.api_bundle.openapi["components"]["schemas"][ref_name]

required = body_schema.get("required", [])
properties = body_schema.get("properties", {})
for name, property in properties.items():
@@ -186,6 +198,8 @@ class ApiTool(Tool):
if property.get("format") == "binary":
f = parameters[name]
files.append((name, (f.filename, download(f), f.mime_type)))
elif "$ref" in property:
body[name] = parameters[name]
else:
# convert type
body[name] = self._convert_body_property_type(property, parameters[name])

Loading…
취소
저장