Results of 1 - 2 of about 2 for Literal (0.004 sec.)
- クエリパラメータモデル 11228
- クエリパラメータモデル もし関連する 複数のクエリパラメータ から成るグループがあるなら、それらを宣言するために、 Pydanticモデル を作成できます。 こうすることで、 複数の場所 で そのPydanticモデルを再利用 でき、バリデーションやメタデータを、す
...ラメータ を Pydanticモデル で宣言し、さらに、それを Query として宣言しましょう: Python 3.10+ from typing import Annotated , Literal from fastapi import FastAPI , Query from pydantic import BaseModel , Field app = FastAPI () class FilterParams ( BaseModel...): limit : int = Field ( 100 , gt = 0 , le = 100 ) offset : int = Field ( 0 , ge = 0 ) order_by : Literal [ "created_at" , "updated_at" ] = "created_at" tags : list [ str ] = [] @app . get ( "/items/" ) async def read_items ( fi...tated from fastapi import FastAPI , Query from pydantic import BaseModel , Field from typing_extensions import Annotated , Literal app = FastAPI () class FilterParams ( BaseModel ): limit : int = Field ( 100 , gt = 0 , le = 100 ) offset : int = Field (... - https://man.mtool.work/fastapi/0.115/tutorial/query-param-models/
- Release Notes 7485
- Release Notes Latest Changes 0.115.11 Fixes ? Add docs examples and tests (support) for Annotated custom validations, like AfterValidator , revert #13440 . PR #13442 by @tiangolo . New docs: Query Parameters and String Validations - Custom
...rs with Pydantic models. ? Query Parameter Models Use Pydantic models for Query parameters: from typing import Annotated , Literal from fastapi import FastAPI , Query from pydantic import BaseModel , Field app = FastAPI () class FilterParams ( BaseModel...): limit : int = Field ( 100 , gt = 0 , le = 100 ) offset : int = Field ( 0 , ge = 0 ) order_by : Literal [ "created_at" , "updated_at" ] = "created_at" tags : list [ str ] = [] @app . get ( "/items/" ) async def read_items ( fi...and Cookie parameters). To achieve it, use Pydantic's model_config = {"extra": "forbid"} : from typing import Annotated , Literal from fastapi import FastAPI , Query from pydantic import BaseModel , Field app = FastAPI () class FilterParams ( BaseModel... - https://man.mtool.work/fastapi/0.115/release-notes/
PREV
1
NEXT