From 320ac73d1b74be704b4162ef15a99d40a1e47a2b Mon Sep 17 00:00:00 2001 From: junjun Date: Fri, 12 Dec 2025 11:18:16 +0800 Subject: [PATCH] feat: Add Api Docs --- backend/apps/datasource/api/table_relation.py | 14 ++++++++------ backend/apps/mcp/mcp.py | 2 +- backend/apps/swagger/i18n.py | 11 ++++++++++- backend/apps/swagger/locales/en.json | 13 ++++++++++++- backend/apps/swagger/locales/zh.json | 13 ++++++++++++- 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/backend/apps/datasource/api/table_relation.py b/backend/apps/datasource/api/table_relation.py index 6a65060a..af7f2245 100644 --- a/backend/apps/datasource/api/table_relation.py +++ b/backend/apps/datasource/api/table_relation.py @@ -2,16 +2,18 @@ # Date: 2025/9/24 from typing import List -from fastapi import APIRouter +from fastapi import APIRouter, Path from apps.datasource.models.datasource import CoreDatasource +from apps.swagger.i18n import PLACEHOLDER_PREFIX from common.core.deps import SessionDep -router = APIRouter(tags=["table_relation"], prefix="/table_relation") +router = APIRouter(tags=["Table Relation"], prefix="/table_relation") -@router.post("/save/{ds_id}") -async def save_relation(session: SessionDep, ds_id: int, relation: List[dict]): +@router.post("/save/{ds_id}", response_model=List[dict], summary=f"{PLACEHOLDER_PREFIX}tr_save") +async def save_relation(session: SessionDep, relation: List[dict], + ds_id: int = Path(..., description=f"{PLACEHOLDER_PREFIX}ds_id")): ds = session.get(CoreDatasource, ds_id) if ds: ds.table_relation = relation @@ -21,8 +23,8 @@ async def save_relation(session: SessionDep, ds_id: int, relation: List[dict]): return True -@router.post("/get/{ds_id}") -async def save_relation(session: SessionDep, ds_id: int): +@router.post("/get/{ds_id}", response_model=List[dict], summary=f"{PLACEHOLDER_PREFIX}tr_get") +async def save_relation(session: SessionDep, ds_id: int = Path(..., description=f"{PLACEHOLDER_PREFIX}ds_id")): ds = session.get(CoreDatasource, ds_id) if ds: return ds.table_relation if ds.table_relation else [] diff --git a/backend/apps/mcp/mcp.py b/backend/apps/mcp/mcp.py index 76f3feea..0085c7fd 100644 --- a/backend/apps/mcp/mcp.py +++ b/backend/apps/mcp/mcp.py @@ -33,7 +33,7 @@ tokenUrl=f"{settings.API_V1_STR}/login/access-token" ) -router = APIRouter(tags=["mcp"], prefix="/mcp") +router = APIRouter(tags=["mcp"], prefix="/mcp", include_in_schema=False) # @router.post("/access_token", operation_id="access_token") diff --git a/backend/apps/swagger/i18n.py b/backend/apps/swagger/i18n.py index 17073f06..30aa423d 100644 --- a/backend/apps/swagger/i18n.py +++ b/backend/apps/swagger/i18n.py @@ -45,7 +45,16 @@ def load_translation(lang: str) -> Dict[str, str]: { "name": "Datasource", "description": f"{PLACEHOLDER_PREFIX}ds_api" - } + }, + { + "name": "Table Relation", + "description": f"{PLACEHOLDER_PREFIX}tr_api" + }, + { + "name": "Data Permission", + "description": f"{PLACEHOLDER_PREFIX}per_api" + }, + ] diff --git a/backend/apps/swagger/locales/en.json b/backend/apps/swagger/locales/en.json index 96957e54..84b22f85 100644 --- a/backend/apps/swagger/locales/en.json +++ b/backend/apps/swagger/locales/en.json @@ -21,5 +21,16 @@ "ds_edit_field": "Edit Field Info", "ds_preview_data": "Preview Data", "ds_upload_excel": "Upload Excel", - "ds_excel": "File" + "ds_excel": "File", + + "per_api": "Data Permission", + "per_save": "Save Permission", + "per_delete": "Delete Permission", + "per_id": "Permission ID", + "per_list": "Get Permission List", + "per_get": "Get Permission Item Info", + + "tr_api": "Table Relation", + "tr_save": "Save Table Relation", + "tr_get": "Get Table Relation" } \ No newline at end of file diff --git a/backend/apps/swagger/locales/zh.json b/backend/apps/swagger/locales/zh.json index f920b85f..c324e78c 100644 --- a/backend/apps/swagger/locales/zh.json +++ b/backend/apps/swagger/locales/zh.json @@ -21,5 +21,16 @@ "ds_edit_field": "编辑字段信息", "ds_preview_data": "预览数据", "ds_upload_excel": "上传Excel", - "ds_excel": "文件" + "ds_excel": "文件", + + "per_api": "数据权限", + "per_save": "保存权限", + "per_delete": "删除权限", + "per_id": "权限 ID", + "per_list": "获取权限列表", + "per_get": "获取单条权限详情", + + "tr_api": "表关联关系", + "tr_save": "保存关联关系", + "tr_get": "查询关联关系" } \ No newline at end of file