- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 64 for BaseModel (0.04 sec)
-
tests/test_pydantic_v1_error.py
from fastapi.exceptions import PydanticV1NotSupportedError with warnings.catch_warnings(): warnings.simplefilter("ignore", UserWarning) from pydantic.v1 import BaseModel def test_raises_pydantic_v1_model_in_endpoint_param() -> None: class ParamModelV1(BaseModel): name: str app = FastAPI() with pytest.raises(PydanticV1NotSupportedError): @app.post("/param")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 12:54:56 UTC 2025 - 2.3K bytes - Viewed (0) -
fastapi/utils.py
from pydantic import BaseModel from pydantic.fields import FieldInfo from typing_extensions import Literal from ._compat import v2 if TYPE_CHECKING: # pragma: nocover from .routing import APIRoute # Cache for `create_cloned_field` _CLONED_TYPES_CACHE: MutableMapping[type[BaseModel], type[BaseModel]] = ( WeakKeyDictionary() )Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 12:54:56 UTC 2025 - 5.1K bytes - Viewed (0) -
tests/test_jsonable_encoder.py
class RoleEnum(Enum): admin = "admin" normal = "normal" class ModelWithConfig(BaseModel): role: Optional[RoleEnum] = None model_config = {"use_enum_values": True} class ModelWithAlias(BaseModel): foo: str = Field(alias="Foo") class ModelWithDefault(BaseModel): foo: str = ... # type: ignore bar: str = "bar" bla: str = "bla" def test_encode_dict():
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 12:54:56 UTC 2025 - 9.2K bytes - Viewed (0) -
tests/test_datetime_custom_encoder.py
from datetime import datetime, timezone from fastapi import FastAPI from fastapi.testclient import TestClient from pydantic import BaseModel def test_pydanticv2(): from pydantic import field_serializer class ModelWithDatetimeField(BaseModel): dt_field: datetime @field_serializer("dt_field") def serialize_datetime(self, dt_field: datetime):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 12:54:56 UTC 2025 - 817 bytes - Viewed (0) -
tests/test_union_body_discriminator.py
from inline_snapshot import snapshot from pydantic import BaseModel, Field from typing_extensions import Literal def test_discriminator_pydantic_v2() -> None: from pydantic import Tag app = FastAPI() class FirstItem(BaseModel): value: Literal["first"] price: int class OtherItem(BaseModel): value: Literal["other"] price: float
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 7.1K bytes - Viewed (0) -
tests/test_sub_callbacks.py
from fastapi.testclient import TestClient from pydantic import BaseModel, HttpUrl app = FastAPI() class Invoice(BaseModel): id: str title: Optional[str] = None customer: str total: float class InvoiceEvent(BaseModel): description: str paid: bool class InvoiceEventReceived(BaseModel): ok: bool invoices_callback_router = APIRouter()
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 12.9K bytes - Viewed (0) -
fastapi/_compat/shared.py
from pydantic import v1 return isinstance(obj, v1.BaseModel) def is_pydantic_v1_model_class(cls: Any) -> bool: with warnings.catch_warnings(): warnings.simplefilter("ignore", UserWarning) from pydantic import v1 return lenient_issubclass(cls, v1.BaseModel) def annotation_is_pydantic_v1(annotation: Any) -> bool:Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 12:54:56 UTC 2025 - 6.7K bytes - Viewed (0) -
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) -
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) -
tests/test_request_params/test_header/test_optional_str.py
from fastapi.testclient import TestClient from pydantic import BaseModel, Field app = FastAPI() # ===================================================================================== # Without aliases @app.get("/optional-str") async def read_optional_str(p: Annotated[Optional[str], Header()] = None): return {"p": p} class HeaderModelOptionalStr(BaseModel): p: Optional[str] = None
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 8.2K bytes - Viewed (0)