Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(api): skip non-method keys in Swagger path items instead of failing import (#44992)
梦想陆地的鱼5f9f0ce5221a
diff --git a/api/core/tools/utils/parser.py b/api/core/tools/utils/parser.pyindex a5a9e726648..3e6c70db0c3 100644--- a/api/core/tools/utils/parser.py+++ b/api/core/tools/utils/parser.py@@ -319,22 +319,26 @@ class ApiBasedToolSchemaParser:raise ToolApiSchemaError("No paths found in the swagger yaml.")# convert paths+ http_methods = ("get", "post", "put", "delete", "patch", "head", "options", "trace")for path, path_item in swagger["paths"].items():converted_openapi["paths"][path] = {}for method, operation in path_item.items():+ # A Path Item Object may carry non-operation keys such as+ # path-level parameters; only HTTP methods define operations.+ method = str(method).lower()+ if method not in http_methods:+ continueif "operationId" not in operation:raise ToolApiSchemaError(f"No operationId found in operation {method} {path}.")- if ("summary" not in operation or len(operation["summary"]) == 0) and (- "description" not in operation or len(operation["description"]) == 0- ):+ if not operation.get("summary") and not operation.get("description"):if warning is not None:warning["missing_summary"] = f"No summary or description found in operation {method} {path}."converted_openapi["paths"][path][method] = {"operationId": operation["operationId"],- "summary": operation.get("summary", ""),- "description": operation.get("description", ""),+ "summary": operation.get("summary") or "",+ "description": operation.get("description") or "","parameters": operation.get("parameters", []),"responses": operation.get("responses", {}),}diff --git a/api/tests/unit_tests/core/tools/utils/test_parser.py b/api/tests/unit_tests/core/tools/utils/test_parser.pyindex 00dcdf5c873..bd972e1e4da 100644--- a/api/tests/unit_tests/core/tools/utils/test_parser.py+++ b/api/tests/unit_tests/core/tools/utils/test_parser.py@@ -314,6 +314,35 @@ def test_parse_swagger_to_openapi_branches():assert warning["missing_summary"].startswith("No summary or description found")+def test_parse_swagger_to_openapi_skips_path_level_parameters():+ """Swagger path items may carry non-operation keys like path-level parameters."""+ converted = ApiBasedToolSchemaParser.parse_swagger_to_openapi(+ {+ "servers": [{"url": "https://x"}],+ "paths": {+ "/items": {+ "parameters": [{"name": "limit", "in": "query", "type": "integer"}],+ "get": {"operationId": "listItems", "summary": "List items", "responses": {}},+ }+ },+ }+ )++ assert converted["paths"]["/items"]["get"]["operationId"] == "listItems"+ assert "parameters" not in converted["paths"]["/items"]+++def test_parse_swagger_to_openapi_null_summary_does_not_crash():+ converted = ApiBasedToolSchemaParser.parse_swagger_to_openapi(+ {+ "servers": [{"url": "https://x"}],+ "paths": {"/a": {"get": {"operationId": "getA", "summary": None, "responses": {}}}},+ }+ )++ assert converted["paths"]["/a"]["get"]["summary"] == ""++def test_parse_openai_plugin_json_branches(app):with app.test_request_context():with pytest.raises(ToolProviderNotFoundError, match="Invalid openai plugin json"):