mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
feat: Add Api Docs
This commit is contained in:
@@ -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 []
|
||||
|
||||
@@ -33,7 +33,7 @@ reusable_oauth2 = XOAuth2PasswordBearer(
|
||||
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")
|
||||
|
||||
@@ -45,7 +45,16 @@ tags_metadata = [
|
||||
{
|
||||
"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"
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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": "查询关联关系"
|
||||
}
|
||||
Reference in New Issue
Block a user