Home / Function/ add_param_to_fields() — fastapi Function Reference

add_param_to_fields() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  206d3183_bfaa_d681_38b1_42f425b7a046["add_param_to_fields()"]
  9e602cbf_3139_86ae_5666_97b8806942de["utils.py"]
  206d3183_bfaa_d681_38b1_42f425b7a046 -->|defined in| 9e602cbf_3139_86ae_5666_97b8806942de
  097a7e41_8095_d61f_b849_128514c58040["get_dependant()"]
  097a7e41_8095_d61f_b849_128514c58040 -->|calls| 206d3183_bfaa_d681_38b1_42f425b7a046
  style 206d3183_bfaa_d681_38b1_42f425b7a046 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/dependencies/utils.py lines 532–545

def add_param_to_fields(*, field: ModelField, dependant: Dependant) -> None:
    field_info = field.field_info
    field_info_in = getattr(field_info, "in_", None)
    if field_info_in == params.ParamTypes.path:
        dependant.path_params.append(field)
    elif field_info_in == params.ParamTypes.query:
        dependant.query_params.append(field)
    elif field_info_in == params.ParamTypes.header:
        dependant.header_params.append(field)
    else:
        assert field_info_in == params.ParamTypes.cookie, (
            f"non-body parameters must be in path, query, header or cookie: {field.name}"
        )
        dependant.cookie_params.append(field)

Subdomains

Called By

Frequently Asked Questions

What does add_param_to_fields() do?
add_param_to_fields() is a function in the fastapi codebase, defined in fastapi/dependencies/utils.py.
Where is add_param_to_fields() defined?
add_param_to_fields() is defined in fastapi/dependencies/utils.py at line 532.
What calls add_param_to_fields()?
add_param_to_fields() is called by 1 function(s): get_dependant.

Analyze Your Own Codebase

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

Try Supermodel Free