FastAPI教程-路径参数-Path()参数校验-Swagger‑UI显示校验信息 作者:马育民 • 2026-08-13 11:06 • 阅读:10001 # 例子 在 `Path` 中设置 `description` 参数,可以在 Swagger‑UI 显示详细信息(仅在此处有用) 如下: ``` from fastapi import FastAPI,Path app = FastAPI() @app.get('/student/{age}') async def get_student(age: int=Path(...,ge=10,le=120,description="年龄大于等于10岁,小于等于120岁")): return {'msg': f'年龄{age}'} ``` ### 访问Swagger‑UI 访问:http://127.0.0.1:8000/docs ,显示如下: [](http://www.malaoshi.top/upload/0/0/1GW3qzjNBIoD.png) 原文出处:/show_1GW3qzk5bORI.html