Coverage for docs_src/query_param_models/tutorial001_py39.py: 100%
12 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 limit: int = Field(100, gt=0, le=100) 1abcd
10 offset: int = Field(0, ge=0) 1abcd
11 order_by: Literal["created_at", "updated_at"] = "created_at" 1abcd
12 tags: list[str] = [] 1abcd
15@app.get("/items/") 1abcd
16async def read_items(filter_query: FilterParams = Query()): 1abcd
17 return filter_query 1efghijklmnop