2026-05-11 05:18:16 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from app.core.config import get_settings
|
|
|
|
|
from app.main import create_app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_openapi_schema_includes_documented_backend_routes() -> None:
|
|
|
|
|
schema = create_app().openapi()
|
|
|
|
|
|
|
|
|
|
assert schema["info"]["title"] == get_settings().app_name
|
|
|
|
|
assert any(tag["name"] == "agent-assets" for tag in schema["tags"])
|
|
|
|
|
assert any(tag["name"] == "knowledge" for tag in schema["tags"])
|
2026-05-12 01:26:13 +00:00
|
|
|
assert any(tag["name"] == "ontology" for tag in schema["tags"])
|
|
|
|
|
assert any(tag["name"] == "orchestrator" for tag in schema["tags"])
|
2026-05-11 05:18:16 +00:00
|
|
|
|
|
|
|
|
agent_assets_post = schema["paths"]["/api/v1/agent-assets"]["post"]
|
|
|
|
|
assert agent_assets_post["summary"] == "创建 Agent 资产"
|
|
|
|
|
assert any(param["name"] == "x-actor" for param in agent_assets_post["parameters"])
|
|
|
|
|
|
|
|
|
|
knowledge_upload_post = schema["paths"]["/api/v1/knowledge/documents"]["post"]
|
|
|
|
|
assert knowledge_upload_post["summary"] == "上传知识库文档"
|
|
|
|
|
assert "application/octet-stream" in knowledge_upload_post["requestBody"]["content"]
|
|
|
|
|
|
|
|
|
|
knowledge_callback_post = schema["paths"][
|
|
|
|
|
"/api/v1/knowledge/documents/{document_id}/onlyoffice/callback"
|
|
|
|
|
]["post"]
|
|
|
|
|
assert knowledge_callback_post["summary"] == "接收 ONLYOFFICE 回调"
|
|
|
|
|
assert "application/json" in knowledge_callback_post["requestBody"]["content"]
|
|
|
|
|
|
2026-05-12 01:26:13 +00:00
|
|
|
ontology_parse_post = schema["paths"]["/api/v1/ontology/parse"]["post"]
|
|
|
|
|
assert ontology_parse_post["summary"] == "解析自然语言为语义本体"
|
|
|
|
|
assert "application/json" in ontology_parse_post["requestBody"]["content"]
|
|
|
|
|
|
|
|
|
|
orchestrator_run_post = schema["paths"]["/api/v1/orchestrator/run"]["post"]
|
|
|
|
|
assert orchestrator_run_post["summary"] == "运行 Orchestrator 统一调度"
|
|
|
|
|
assert "application/json" in orchestrator_run_post["requestBody"]["content"]
|
|
|
|
|
|
2026-05-11 05:18:16 +00:00
|
|
|
root_get = schema["paths"]["/"]["get"]
|
|
|
|
|
assert root_get["summary"] == "服务根检查"
|