Home / File/ test_response_by_alias.py — fastapi Source File

test_response_by_alias.py — fastapi Source File

Architecture documentation for test_response_by_alias.py, a python file in the fastapi codebase. 4 imports, 0 dependents.

File python FastAPI Responses 4 imports 19 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  6f861856_fac2_cab6_ed64_8a5d89aac432["test_response_by_alias.py"]
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  6f861856_fac2_cab6_ed64_8a5d89aac432 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  6f861856_fac2_cab6_ed64_8a5d89aac432 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  6f861856_fac2_cab6_ed64_8a5d89aac432 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"]
  6f861856_fac2_cab6_ed64_8a5d89aac432 --> 6913fbd4_39df_d14b_44bb_522e99b65b90
  style 6f861856_fac2_cab6_ed64_8a5d89aac432 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from fastapi import FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel, ConfigDict, Field

app = FastAPI()


class Model(BaseModel):
    name: str = Field(alias="alias")


class ModelNoAlias(BaseModel):
    name: str

    model_config = ConfigDict(
        json_schema_extra={
            "description": (
                "response_model_by_alias=False is basically a quick hack, to support "
                "proper OpenAPI use another model with the correct field names"
            )
        }
    )


@app.get("/dict", response_model=Model, response_model_by_alias=False)
def read_dict():
    return {"alias": "Foo"}


@app.get("/model", response_model=Model, response_model_by_alias=False)
def read_model():
    return Model(alias="Foo")


@app.get("/list", response_model=list[Model], response_model_by_alias=False)
def read_list():
    return [{"alias": "Foo"}, {"alias": "Bar"}]


@app.get("/by-alias/dict", response_model=Model)
def by_alias_dict():
    return {"alias": "Foo"}


@app.get("/by-alias/model", response_model=Model)
def by_alias_model():
    return Model(alias="Foo")


@app.get("/by-alias/list", response_model=list[Model])
def by_alias_list():
    return [{"alias": "Foo"}, {"alias": "Bar"}]


@app.get("/no-alias/dict", response_model=ModelNoAlias)
def no_alias_dict():
    return {"name": "Foo"}


// ... (271 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_response_by_alias.py do?
test_response_by_alias.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in test_response_by_alias.py?
test_response_by_alias.py defines 19 function(s): by_alias_dict, by_alias_list, by_alias_model, no_alias_dict, no_alias_list, no_alias_model, read_dict, read_list, read_model, test_openapi_schema, and 9 more.
What does test_response_by_alias.py depend on?
test_response_by_alias.py imports 4 module(s): __init__.py, inline_snapshot, pydantic, testclient.py.
Where is test_response_by_alias.py in the architecture?
test_response_by_alias.py is located at tests/test_response_by_alias.py (domain: FastAPI, subdomain: Responses, directory: tests).

Analyze Your Own Codebase

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

Try Supermodel Free