- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 217 for forbid (0.05 sec)
-
docs/en/docs/tutorial/request-form-models.md
</div> ## Forbid Extra Form Fields In some special use cases (probably not very common), you might want to **restrict** the form fields to only those declared in the Pydantic model. And **forbid** any **extra** fields. /// note This is supported since FastAPI version `0.114.0`. 🤓 /// You can use Pydantic's model configuration to `forbid` any `extra` fields: //// tab | Python 3.9+
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 2.8K bytes - Viewed (0) -
tests/test_additional_properties_bool.py
from fastapi.testclient import TestClient from pydantic import BaseModel, ConfigDict class FooBaseModel(BaseModel): if PYDANTIC_V2: model_config = ConfigDict(extra="forbid") else: class Config: extra = "forbid" class Foo(FooBaseModel): pass app = FastAPI() @app.post("/") async def post( foo: Union[Foo, None] = None, ): return foo
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 4.2K bytes - Viewed (0) -
docs_src/request_form_models/tutorial002.py
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Sep 06 17:31:18 UTC 2024 - 267 bytes - Viewed (0) -
docs_src/request_form_models/tutorial002_pv1_an.py
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Sep 06 17:31:18 UTC 2024 - 322 bytes - Viewed (0) -
docs_src/cookie_param_models/tutorial002_pv1_an_py39.py
from typing import Annotated, Union from fastapi import Cookie, FastAPI from pydantic import BaseModel app = FastAPI() class Cookies(BaseModel): class Config: extra = "forbid" session_id: str fatebook_tracker: Union[str, None] = None googall_tracker: Union[str, None] = None @app.get("/items/") async def read_items(cookies: Annotated[Cookies, Cookie()]):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Sep 17 18:54:10 UTC 2024 - 406 bytes - Viewed (0) -
docs/en/docs/tutorial/query-param-models.md
<div class="screenshot"> <img src="/img/tutorial/query-param-models/image01.png"> </div> ## Forbid Extra Query Parameters In some special use cases (probably not very common), you might want to **restrict** the query parameters that you want to receive. You can use Pydantic's model configuration to `forbid` any `extra` fields: //// tab | Python 3.10+ ```Python hl_lines="10"
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 3.8K bytes - Viewed (0) -
docs_src/cookie_param_models/tutorial002_pv1_an.py
from typing import Union from fastapi import Cookie, FastAPI from pydantic import BaseModel from typing_extensions import Annotated app = FastAPI() class Cookies(BaseModel): class Config: extra = "forbid" session_id: str fatebook_tracker: Union[str, None] = None googall_tracker: Union[str, None] = None @app.get("/items/") async def read_items(cookies: Annotated[Cookies, Cookie()]):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Sep 17 18:54:10 UTC 2024 - 435 bytes - Viewed (0) -
docs_src/query_param_models/tutorial002_an_py310.py
from typing import Annotated, Literal from fastapi import FastAPI, Query from pydantic import BaseModel, Field app = FastAPI() class FilterParams(BaseModel): model_config = {"extra": "forbid"} 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/")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Sep 17 18:54:10 UTC 2024 - 483 bytes - Viewed (0) -
docs_src/query_param_models/tutorial002_pv1_an.py
from fastapi import FastAPI, Query from pydantic import BaseModel, Field from typing_extensions import Annotated, Literal app = FastAPI() class FilterParams(BaseModel): class Config: extra = "forbid" 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/")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Sep 17 18:54:10 UTC 2024 - 522 bytes - Viewed (0) -
docs_src/header_param_models/tutorial002_py310.py
from fastapi import FastAPI, Header from pydantic import BaseModel app = FastAPI() class CommonHeaders(BaseModel): model_config = {"extra": "forbid"} host: str save_data: bool if_modified_since: str | None = None traceparent: str | None = None x_tag: list[str] = [] @app.get("/items/") async def read_items(headers: CommonHeaders = Header()):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Sep 17 18:54:10 UTC 2024 - 392 bytes - Viewed (0)