- Sort Score
- Result 10 results
- Languages All
Results 111 - 120 of 346 for BaseModel (0.04 sec)
-
tests/test_request_params/test_form/test_optional_list.py
from typing import Annotated, Optional import pytest from fastapi import FastAPI, Form from fastapi.testclient import TestClient from pydantic import BaseModel, Field from .utils import get_body_model_name app = FastAPI() # ===================================================================================== # Without aliases @app.post("/optional-list-str", operation_id="optional_list_str") async def read_optional_list_str(
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 9.9K bytes - Viewed (0) -
docs_src/response_model/tutorial001_py310.py
from typing import Any from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: str | None = None price: float tax: float | None = None tags: list[str] = [] @app.post("/items/", response_model=Item) async def create_item(item: Item) -> Any: return item @app.get("/items/", response_model=list[Item])
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Jan 07 13:45:48 UTC 2023 - 537 bytes - Viewed (0) -
docs_src/handling_errors/tutorial005_py39.py
from fastapi.responses import JSONResponse from pydantic import BaseModel app = FastAPI() @app.exception_handler(RequestValidationError) async def validation_exception_handler(request: Request, exc: RequestValidationError): return JSONResponse( status_code=422, content=jsonable_encoder({"detail": exc.errors(), "body": exc.body}), ) class Item(BaseModel): title: str size: int
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 626 bytes - Viewed (0) -
docs_src/response_model/tutorial001_01_py39.py
from typing import Union from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: Union[str, None] = None price: float tax: Union[float, None] = None tags: list[str] = [] @app.post("/items/") async def create_item(item: Item) -> Item: return item @app.get("/items/") async def read_items() -> list[Item]:
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Jan 07 13:45:48 UTC 2023 - 507 bytes - Viewed (0) -
tests/test_union_body_discriminator_annotated.py
from inline_snapshot import snapshot from pydantic import BaseModel @pytest.fixture(name="client") def client_fixture() -> TestClient: from fastapi import Body from pydantic import Discriminator, Tag class Cat(BaseModel): pet_type: str = "cat" meows: int class Dog(BaseModel): pet_type: str = "dog" barks: float def get_pet_type(v):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 20 15:55:38 UTC 2025 - 7.7K bytes - Viewed (0) -
docs_src/response_model/tutorial004_py310.py
from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: str | None = None price: float tax: float = 10.5 tags: list[str] = [] items = { "foo": {"name": "Foo", "price": 50.2}, "bar": {"name": "Bar", "description": "The bartenders", "price": 62, "tax": 20.2},
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jan 07 14:11:31 UTC 2022 - 595 bytes - Viewed (0) -
docs_src/schema_extra_example/tutorial004_py310.py
from fastapi import Body, FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: str | None = None price: float tax: float | None = None @app.put("/items/{item_id}") async def update_item( *, item_id: int, item: Item = Body( examples=[ { "name": "Foo", "description": "A very nice Item",
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Jul 01 16:43:29 UTC 2023 - 786 bytes - Viewed (0) -
docs_src/openapi_webhooks/tutorial001_py39.py
from datetime import datetime from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Subscription(BaseModel): username: str monthly_fee: float start_date: datetime @app.webhooks.post("new-subscription") def new_subscription(body: Subscription): """ When a new user subscribes to your service we'll send you a POST request with this
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 550 bytes - Viewed (0) -
tests/test_schema_ref_pydantic_v2.py
import pytest from fastapi import FastAPI from fastapi.testclient import TestClient from inline_snapshot import snapshot from pydantic import BaseModel, ConfigDict, Field @pytest.fixture(name="client") def get_client(): app = FastAPI() class ModelWithRef(BaseModel): ref: str = Field(validation_alias="$ref", serialization_alias="$ref")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 20 15:55:38 UTC 2025 - 2.1K bytes - Viewed (0) -
fastapi/_compat/v2.py
def create_body_model( *, fields: Sequence[ModelField], model_name: str ) -> type[BaseModel]: field_params = {f.name: (f.field_info.annotation, f.field_info) for f in fields} BodyModel: type[BaseModel] = create_model(model_name, **field_params) # type: ignore[call-overload] return BodyModel def get_model_fields(model: type[BaseModel]) -> list[ModelField]: model_fields: list[ModelField] = []
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 12:54:56 UTC 2025 - 19.1K bytes - Viewed (0)