Coverage for docs_src/query_param_models/tutorial002_py39.py: 100%
13 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-01-13 13:38 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-01-13 13:38 +0000
1from fastapi import FastAPI, Query 1abcd
2from pydantic import BaseModel, Field 1abcd
3from typing_extensions import Literal 1abcd
5app = FastAPI() 1abcd
8class FilterParams(BaseModel): 1abcd
9 model_config = {"extra": "forbid"} 1abcd
11 limit: int = Field(100, gt=0, le=100) 1abcd
12 offset: int = Field(0, ge=0) 1abcd
13 order_by: Literal["created_at", "updated_at"] = "created_at" 1abcd
14 tags: list[str] = [] 1abcd
17@app.get("/items/") 1abcd
18async def read_items(filter_query: FilterParams = Query()): 1abcd
19 return filter_query 1efghijkl