Home / Function/ __init__() — fastapi Function Reference

__init__() — fastapi Function Reference

Architecture documentation for the __init__() function in routing.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  0df3979a_d2ac_6dd9_1bb1_6629b89a941b["__init__()"]
  400570c6_159a_07b5_2e94_ba32f34336f9["APIWebSocketRoute"]
  0df3979a_d2ac_6dd9_1bb1_6629b89a941b -->|defined in| 400570c6_159a_07b5_2e94_ba32f34336f9
  097a7e41_8095_d61f_b849_128514c58040["get_dependant()"]
  0df3979a_d2ac_6dd9_1bb1_6629b89a941b -->|calls| 097a7e41_8095_d61f_b849_128514c58040
  3a3fcbe8_4556_0002_0c59_0917c6099b2b["get_parameterless_sub_dependant()"]
  0df3979a_d2ac_6dd9_1bb1_6629b89a941b -->|calls| 3a3fcbe8_4556_0002_0c59_0917c6099b2b
  df2bd000_d29c_ac4b_5eca_426e3122a385["get_flat_dependant()"]
  0df3979a_d2ac_6dd9_1bb1_6629b89a941b -->|calls| df2bd000_d29c_ac4b_5eca_426e3122a385
  18580490_8a5f_0766_c8e1_329e703c7527["_should_embed_body_fields()"]
  0df3979a_d2ac_6dd9_1bb1_6629b89a941b -->|calls| 18580490_8a5f_0766_c8e1_329e703c7527
  40cf508d_1e02_35ba_ab86_a9399504216d["websocket_session()"]
  0df3979a_d2ac_6dd9_1bb1_6629b89a941b -->|calls| 40cf508d_1e02_35ba_ab86_a9399504216d
  a0d87950_5de5_3ab2_72f7_0a20a6e00434["get_websocket_app()"]
  0df3979a_d2ac_6dd9_1bb1_6629b89a941b -->|calls| a0d87950_5de5_3ab2_72f7_0a20a6e00434
  style 0df3979a_d2ac_6dd9_1bb1_6629b89a941b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/routing.py lines 515–547

    def __init__(
        self,
        path: str,
        endpoint: Callable[..., Any],
        *,
        name: Optional[str] = None,
        dependencies: Optional[Sequence[params.Depends]] = None,
        dependency_overrides_provider: Optional[Any] = None,
    ) -> None:
        self.path = path
        self.endpoint = endpoint
        self.name = get_name(endpoint) if name is None else name
        self.dependencies = list(dependencies or [])
        self.path_regex, self.path_format, self.param_convertors = compile_path(path)
        self.dependant = get_dependant(
            path=self.path_format, call=self.endpoint, scope="function"
        )
        for depends in self.dependencies[::-1]:
            self.dependant.dependencies.insert(
                0,
                get_parameterless_sub_dependant(depends=depends, path=self.path_format),
            )
        self._flat_dependant = get_flat_dependant(self.dependant)
        self._embed_body_fields = _should_embed_body_fields(
            self._flat_dependant.body_params
        )
        self.app = websocket_session(
            get_websocket_app(
                dependant=self.dependant,
                dependency_overrides_provider=dependency_overrides_provider,
                embed_body_fields=self._embed_body_fields,
            )
        )

Domain

Subdomains

Defined In

Frequently Asked Questions

What does __init__() do?
__init__() is a function in the fastapi codebase, defined in fastapi/routing.py.
Where is __init__() defined?
__init__() is defined in fastapi/routing.py at line 515.
What does __init__() call?
__init__() calls 6 function(s): _should_embed_body_fields, get_dependant, get_flat_dependant, get_parameterless_sub_dependant, get_websocket_app, websocket_session.

Analyze Your Own Codebase

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

Try Supermodel Free