Home / Function/ trace() — fastapi Function Reference

trace() — fastapi Function Reference

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

Function python FastAPI Routing calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  1605c2e4_0694_395a_b3dc_f4a9f4da045c["trace()"]
  ecadd3bc_0c58_b4e5_06d8_57da79199adc["APIRouter"]
  1605c2e4_0694_395a_b3dc_f4a9f4da045c -->|defined in| ecadd3bc_0c58_b4e5_06d8_57da79199adc
  07d238dc_2c4f_546e_6ed5_41ac6f3e6c8b["trace()"]
  07d238dc_2c4f_546e_6ed5_41ac6f3e6c8b -->|calls| 1605c2e4_0694_395a_b3dc_f4a9f4da045c
  6a8dad5e_61e5_8086_e2a6_e7db4a0c2ceb["api_route()"]
  1605c2e4_0694_395a_b3dc_f4a9f4da045c -->|calls| 6a8dad5e_61e5_8086_e2a6_e7db4a0c2ceb
  28261a63_2ba9_f1ff_1d1b_475348a45a65["Default()"]
  1605c2e4_0694_395a_b3dc_f4a9f4da045c -->|calls| 28261a63_2ba9_f1ff_1d1b_475348a45a65
  c1d02f65_9a84_123a_bdd4_304e5732f35a["include_router()"]
  1605c2e4_0694_395a_b3dc_f4a9f4da045c -->|calls| c1d02f65_9a84_123a_bdd4_304e5732f35a
  style 1605c2e4_0694_395a_b3dc_f4a9f4da045c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/routing.py lines 4168–4548

    def trace(
        self,
        path: Annotated[
            str,
            Doc(
                """
                The URL path to be used for this *path operation*.

                For example, in `http://example.com/items`, the path is `/items`.
                """
            ),
        ],
        *,
        response_model: Annotated[
            Any,
            Doc(
                """
                The type to use for the response.

                It could be any valid Pydantic *field* type. So, it doesn't have to
                be a Pydantic model, it could be other things, like a `list`, `dict`,
                etc.

                It will be used for:

                * Documentation: the generated OpenAPI (and the UI at `/docs`) will
                    show it as the response (JSON Schema).
                * Serialization: you could return an arbitrary object and the
                    `response_model` would be used to serialize that object into the
                    corresponding JSON.
                * Filtering: the JSON sent to the client will only contain the data
                    (fields) defined in the `response_model`. If you returned an object
                    that contains an attribute `password` but the `response_model` does
                    not include that field, the JSON sent to the client would not have
                    that `password`.
                * Validation: whatever you return will be serialized with the
                    `response_model`, converting any data as necessary to generate the
                    corresponding JSON. But if the data in the object returned is not
                    valid, that would mean a violation of the contract with the client,
                    so it's an error from the API developer. So, FastAPI will raise an
                    error and return a 500 error code (Internal Server Error).

                Read more about it in the
                [FastAPI docs for Response Model](https://fastapi.tiangolo.com/tutorial/response-model/).
                """
            ),
        ] = Default(None),
        status_code: Annotated[
            Optional[int],
            Doc(
                """
                The default status code to be used for the response.

                You could override the status code by returning a response directly.

                Read more about it in the
                [FastAPI docs for Response Status Code](https://fastapi.tiangolo.com/tutorial/response-status-code/).
                """
            ),
        ] = None,
        tags: Annotated[
            Optional[list[Union[str, Enum]]],
            Doc(
                """
                A list of tags to be applied to the *path operation*.

                It will be added to the generated OpenAPI (e.g. visible at `/docs`).

                Read more about it in the
                [FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/#tags).
                """
            ),
        ] = None,
        dependencies: Annotated[
            Optional[Sequence[params.Depends]],
            Doc(
                """
                A list of dependencies (using `Depends()`) to be applied to the
                *path operation*.

                Read more about it in the

Domain

Subdomains

Defined In

Called By

Frequently Asked Questions

What does trace() do?
trace() is a function in the fastapi codebase, defined in fastapi/routing.py.
Where is trace() defined?
trace() is defined in fastapi/routing.py at line 4168.
What does trace() call?
trace() calls 3 function(s): Default, api_route, include_router.
What calls trace()?
trace() is called by 1 function(s): trace.

Analyze Your Own Codebase

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

Try Supermodel Free