Home / Function/ get_fields_from_routes() — fastapi Function Reference

get_fields_from_routes() — fastapi Function Reference

Architecture documentation for the get_fields_from_routes() function in utils.py from the fastapi codebase.

Function python FastAPI Responses calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  ca85dbd8_2c4a_3a15_71e8_da853c7f62ce["get_fields_from_routes()"]
  0dcb823f_ea0d_bd04_752b_a3a3f875bba1["utils.py"]
  ca85dbd8_2c4a_3a15_71e8_da853c7f62ce -->|defined in| 0dcb823f_ea0d_bd04_752b_a3a3f875bba1
  d8a9ec8b_6a53_c575_f568_9201405b8883["get_openapi()"]
  d8a9ec8b_6a53_c575_f568_9201405b8883 -->|calls| ca85dbd8_2c4a_3a15_71e8_da853c7f62ce
  ae5e875d_4a7a_fe4f_43bc_0f9490438b9f["get_flat_params()"]
  ca85dbd8_2c4a_3a15_71e8_da853c7f62ce -->|calls| ae5e875d_4a7a_fe4f_43bc_0f9490438b9f
  style ca85dbd8_2c4a_3a15_71e8_da853c7f62ce fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/openapi/utils.py lines 449–477

def get_fields_from_routes(
    routes: Sequence[BaseRoute],
) -> list[ModelField]:
    body_fields_from_routes: list[ModelField] = []
    responses_from_routes: list[ModelField] = []
    request_fields_from_routes: list[ModelField] = []
    callback_flat_models: list[ModelField] = []
    for route in routes:
        if getattr(route, "include_in_schema", None) and isinstance(
            route, routing.APIRoute
        ):
            if route.body_field:
                assert isinstance(route.body_field, ModelField), (
                    "A request body must be a Pydantic Field"
                )
                body_fields_from_routes.append(route.body_field)
            if route.response_field:
                responses_from_routes.append(route.response_field)
            if route.response_fields:
                responses_from_routes.extend(route.response_fields.values())
            if route.callbacks:
                callback_flat_models.extend(get_fields_from_routes(route.callbacks))
            params = get_flat_params(route.dependant)
            request_fields_from_routes.extend(params)

    flat_models = callback_flat_models + list(
        body_fields_from_routes + responses_from_routes + request_fields_from_routes
    )
    return flat_models

Domain

Subdomains

Called By

Frequently Asked Questions

What does get_fields_from_routes() do?
get_fields_from_routes() is a function in the fastapi codebase, defined in fastapi/openapi/utils.py.
Where is get_fields_from_routes() defined?
get_fields_from_routes() is defined in fastapi/openapi/utils.py at line 449.
What does get_fields_from_routes() call?
get_fields_from_routes() calls 1 function(s): get_flat_params.
What calls get_fields_from_routes()?
get_fields_from_routes() is called by 1 function(s): get_openapi.

Analyze Your Own Codebase

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

Try Supermodel Free