Home / Function/ get_value_or_default() — fastapi Function Reference

get_value_or_default() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  ba32f931_603d_6b3e_d601_c9cf3fce1825["get_value_or_default()"]
  1c2c0e68_6ed1_7632_8c35_00818f97b599["utils.py"]
  ba32f931_603d_6b3e_d601_c9cf3fce1825 -->|defined in| 1c2c0e68_6ed1_7632_8c35_00818f97b599
  27778071_8d5b_35e0_a46c_5aa1fbf21fac["add_api_route()"]
  27778071_8d5b_35e0_a46c_5aa1fbf21fac -->|calls| ba32f931_603d_6b3e_d601_c9cf3fce1825
  c1d02f65_9a84_123a_bdd4_304e5732f35a["include_router()"]
  c1d02f65_9a84_123a_bdd4_304e5732f35a -->|calls| ba32f931_603d_6b3e_d601_c9cf3fce1825
  style ba32f931_603d_6b3e_d601_c9cf3fce1825 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/utils.py lines 123–138

def get_value_or_default(
    first_item: Union[DefaultPlaceholder, DefaultType],
    *extra_items: Union[DefaultPlaceholder, DefaultType],
) -> Union[DefaultPlaceholder, DefaultType]:
    """
    Pass items or `DefaultPlaceholder`s by descending priority.

    The first one to _not_ be a `DefaultPlaceholder` will be returned.

    Otherwise, the first item (a `DefaultPlaceholder`) will be returned.
    """
    items = (first_item,) + extra_items
    for item in items:
        if not isinstance(item, DefaultPlaceholder):
            return item
    return first_item

Domain

Subdomains

Defined In

Frequently Asked Questions

What does get_value_or_default() do?
get_value_or_default() is a function in the fastapi codebase, defined in fastapi/utils.py.
Where is get_value_or_default() defined?
get_value_or_default() is defined in fastapi/utils.py at line 123.
What calls get_value_or_default()?
get_value_or_default() is called by 2 function(s): add_api_route, include_router.

Analyze Your Own Codebase

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

Try Supermodel Free