from typing import Optional, List
from fastapi import APIRouter, Query
app04 = APIRouter()
@app04.get("/query")
def page_limit(page: int = 1, limit: Optional[int] = None):
if limit:
return {"page": page, "limit": limit}
return {"page": page}
@app04.get("/query/bool/conversion")
def type_conversion(param: bool = False):
return param
@app04.get("/query/validations")
def query_params_validate(
value: str = Query(..., title="123", description="不可描述", min_length=8, max_length=16, regex="^a"),
values: List[str] = Query(["v1", "v2"], title="123", description="不可描述", alias="value_list")
):
print(values, type(values))
return value, values