优化API文档,添加参数描述和示例

This commit is contained in:
2026-03-13 15:17:06 +08:00
parent 9a8d851275
commit b513d05611
38 changed files with 5846 additions and 1224 deletions
+22 -7
View File
@@ -1,4 +1,4 @@
from fastapi import APIRouter, Request
from fastapi import APIRouter, Request, Query
from typing import Any, List, Dict, Union
from app.services.tjnetwork import Any, get_all_users, get_user, get_user_schema
@@ -8,14 +8,29 @@ router = APIRouter()
# user 39
###########################################################
@router.get("/getuserschema/")
async def fastapi_get_user_schema(network: str) -> dict[str, dict[Any, Any]]:
@router.get("/getuserschema/", summary="获取用户模式", description="获取指定网络的用户模式定义")
async def fastapi_get_user_schema(network: str = Query(..., description="管网名称(或数据库名称)")) -> dict[str, dict[Any, Any]]:
"""
获取用户模式定义
返回指定网络的用户模式结构定义
"""
return get_user_schema(network)
@router.get("/getuser/")
async def fastapi_get_user(network: str, user_name: str) -> dict[Any, Any]:
@router.get("/getuser/", summary="获取单个用户", description="获取指定网络中的单个用户信息")
async def fastapi_get_user(network: str = Query(..., description="管网名称(或数据库名称)"), user_name: str = Query(..., description="用户名")) -> dict[Any, Any]:
"""
获取用户信息
返回指定网络中指定用户名的详细信息
"""
return get_user(network, user_name)
@router.get("/getallusers/")
async def fastapi_get_all_users(network: str) -> list[dict[Any, Any]]:
@router.get("/getallusers/", summary="获取所有用户", description="获取指定网络的所有用户列表")
async def fastapi_get_all_users(network: str = Query(..., description="管网名称(或数据库名称)")) -> list[dict[Any, Any]]:
"""
获取所有用户列表
返回指定网络中所有用户的信息
"""
return get_all_users(network)