Home / File/ models.py — fastapi Source File

models.py — fastapi Source File

Architecture documentation for models.py, a python file in the fastapi codebase. 8 imports, 9 dependents.

File python FastAPI Applications 8 imports 9 dependents 2 functions 41 classes

Entity Profile

Dependency Diagram

graph LR
  7f688779_6b22_3c15_6514_97dec91c3c30["models.py"]
  07d79a2e_d4e9_0bbb_be90_936274444c8c["collections.abc"]
  7f688779_6b22_3c15_6514_97dec91c3c30 --> 07d79a2e_d4e9_0bbb_be90_936274444c8c
  712b7268_fde0_3ca8_dc06_7aa9a47c77d9["enum"]
  7f688779_6b22_3c15_6514_97dec91c3c30 --> 712b7268_fde0_3ca8_dc06_7aa9a47c77d9
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  7f688779_6b22_3c15_6514_97dec91c3c30 --> 0dda2280_3359_8460_301c_e98c77e78185
  aac750d7_00e7_a28d_9e64_89918311078b["__init__.py"]
  7f688779_6b22_3c15_6514_97dec91c3c30 --> aac750d7_00e7_a28d_9e64_89918311078b
  f6ee72dd_97b3_51a3_85f4_d463e7a86602["logger.py"]
  7f688779_6b22_3c15_6514_97dec91c3c30 --> f6ee72dd_97b3_51a3_85f4_d463e7a86602
  6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"]
  7f688779_6b22_3c15_6514_97dec91c3c30 --> 6913fbd4_39df_d14b_44bb_522e99b65b90
  87f0eda4_1c7f_c164_42ba_f715b8cf0a6b["typing_extensions"]
  7f688779_6b22_3c15_6514_97dec91c3c30 --> 87f0eda4_1c7f_c164_42ba_f715b8cf0a6b
  454bb107_5f20_afb6_5e0d_0b0171c92698["email_validator"]
  7f688779_6b22_3c15_6514_97dec91c3c30 --> 454bb107_5f20_afb6_5e0d_0b0171c92698
  0dcb823f_ea0d_bd04_752b_a3a3f875bba1["utils.py"]
  0dcb823f_ea0d_bd04_752b_a3a3f875bba1 --> 7f688779_6b22_3c15_6514_97dec91c3c30
  24a9a43e_697f_81ce_6a7c_28a423a6f93b["param_functions.py"]
  24a9a43e_697f_81ce_6a7c_28a423a6f93b --> 7f688779_6b22_3c15_6514_97dec91c3c30
  2bb4dd2d_8b8a_6502_751c_38eabb6ae71e["params.py"]
  2bb4dd2d_8b8a_6502_751c_38eabb6ae71e --> 7f688779_6b22_3c15_6514_97dec91c3c30
  fac63c1f_ae18_a88d_487c_0fd6cfe587f0["api_key.py"]
  fac63c1f_ae18_a88d_487c_0fd6cfe587f0 --> 7f688779_6b22_3c15_6514_97dec91c3c30
  81864ff4_3194_3d8a_0ac8_a6193fbdc833["base.py"]
  81864ff4_3194_3d8a_0ac8_a6193fbdc833 --> 7f688779_6b22_3c15_6514_97dec91c3c30
  96278b4c_a391_681f_b974_563be8af72ce["http.py"]
  96278b4c_a391_681f_b974_563be8af72ce --> 7f688779_6b22_3c15_6514_97dec91c3c30
  style 7f688779_6b22_3c15_6514_97dec91c3c30 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from collections.abc import Iterable, Mapping
from enum import Enum
from typing import Annotated, Any, Callable, Optional, Union

from fastapi._compat import with_info_plain_validator_function
from fastapi.logger import logger
from pydantic import (
    AnyUrl,
    BaseModel,
    Field,
    GetJsonSchemaHandler,
)
from typing_extensions import Literal, TypedDict
from typing_extensions import deprecated as typing_deprecated

try:
    import email_validator

    assert email_validator  # make autoflake ignore the unused import
    from pydantic import EmailStr
except ImportError:  # pragma: no cover

    class EmailStr(str):  # type: ignore
        @classmethod
        def __get_validators__(cls) -> Iterable[Callable[..., Any]]:
            yield cls.validate

        @classmethod
        def validate(cls, v: Any) -> str:
            logger.warning(
                "email-validator not installed, email fields will be treated as str.\n"
                "To install, run: pip install email-validator"
            )
            return str(v)

        @classmethod
        def _validate(cls, __input_value: Any, _: Any) -> str:
            logger.warning(
                "email-validator not installed, email fields will be treated as str.\n"
                "To install, run: pip install email-validator"
            )
            return str(__input_value)

        @classmethod
        def __get_pydantic_json_schema__(
            cls, core_schema: Mapping[str, Any], handler: GetJsonSchemaHandler
        ) -> dict[str, Any]:
            return {"type": "string", "format": "email"}

        @classmethod
        def __get_pydantic_core_schema__(
            cls, source: type[Any], handler: Callable[[Any], Mapping[str, Any]]
        ) -> Mapping[str, Any]:
            return with_info_plain_validator_function(cls._validate)


class BaseModelWithConfig(BaseModel):
    model_config = {"extra": "allow"}


// ... (376 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does models.py do?
models.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in models.py?
models.py defines 2 function(s): EmailStr, email_validator.
What does models.py depend on?
models.py imports 8 module(s): __init__.py, collections.abc, email_validator, enum, logger.py, pydantic, typing, typing_extensions.
What files import models.py?
models.py is imported by 9 file(s): api_key.py, base.py, http.py, oauth2.py, open_id_connect_url.py, param_functions.py, params.py, test_openapi_schema_type.py, and 1 more.
Where is models.py in the architecture?
models.py is located at fastapi/openapi/models.py (domain: FastAPI, subdomain: Applications, directory: fastapi/openapi).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free