[FastAPI-08]Path校验-接口信息
from fastapi import FastAPI,Path
app = FastAPI()
# Path校验
'''
限制接口输入的数字大小限制 100-1000
限制字符串输入的字符数量 3-8位
'''
# deprecated 即将废弃
# include_in_schema 隐藏接口
def number(num:int = Path(ge=100,le=1000,
description="数字范围在100~1000之间",
example=100,
deprecated=True,
include_in_schema=False)):
return {"number":num}
@app.get("/word/{name}")
def word(name:str = Path(min_length=3,max_length=8)):
return {"word":name}

浙公网安备 33010602011771号