test_serialize_response_model.py — fastapi Source File
Architecture documentation for test_serialize_response_model.py, a python file in the fastapi codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR cbcf7fa2_afd9_b8ef_c734_42f98fa2cbd6["test_serialize_response_model.py"] 0dda2280_3359_8460_301c_e98c77e78185["typing"] cbcf7fa2_afd9_b8ef_c734_42f98fa2cbd6 --> 0dda2280_3359_8460_301c_e98c77e78185 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] cbcf7fa2_afd9_b8ef_c734_42f98fa2cbd6 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"] cbcf7fa2_afd9_b8ef_c734_42f98fa2cbd6 --> 6913fbd4_39df_d14b_44bb_522e99b65b90 bcc067f0_0107_d76b_204a_6705d20b4cf9["starlette.testclient"] cbcf7fa2_afd9_b8ef_c734_42f98fa2cbd6 --> bcc067f0_0107_d76b_204a_6705d20b4cf9 style cbcf7fa2_afd9_b8ef_c734_42f98fa2cbd6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel, Field
from starlette.testclient import TestClient
app = FastAPI()
class Item(BaseModel):
name: str = Field(alias="aliased_name")
price: Optional[float] = None
owner_ids: Optional[list[int]] = None
@app.get("/items/valid", response_model=Item)
def get_valid():
return Item(aliased_name="valid", price=1.0)
@app.get("/items/coerce", response_model=Item)
def get_coerce():
return Item(aliased_name="coerce", price="1.0")
@app.get("/items/validlist", response_model=list[Item])
def get_validlist():
return [
Item(aliased_name="foo"),
Item(aliased_name="bar", price=1.0),
Item(aliased_name="baz", price=2.0, owner_ids=[1, 2, 3]),
]
@app.get("/items/validdict", response_model=dict[str, Item])
def get_validdict():
return {
"k1": Item(aliased_name="foo"),
"k2": Item(aliased_name="bar", price=1.0),
"k3": Item(aliased_name="baz", price=2.0, owner_ids=[1, 2, 3]),
}
@app.get(
"/items/valid-exclude-unset", response_model=Item, response_model_exclude_unset=True
)
def get_valid_exclude_unset():
return Item(aliased_name="valid", price=1.0)
@app.get(
"/items/coerce-exclude-unset",
response_model=Item,
response_model_exclude_unset=True,
)
def get_coerce_exclude_unset():
return Item(aliased_name="coerce", price="1.0")
@app.get(
// ... (95 more lines)
Domain
Subdomains
Functions
- get_coerce()
- get_coerce_exclude_unset()
- get_valid()
- get_valid_exclude_unset()
- get_validdict()
- get_validdict_exclude_unset()
- get_validlist()
- get_validlist_exclude_unset()
- test_coerce()
- test_coerce_exclude_unset()
- test_valid()
- test_valid_exclude_unset()
- test_validdict()
- test_validdict_exclude_unset()
- test_validlist()
- test_validlist_exclude_unset()
Classes
Dependencies
- __init__.py
- pydantic
- starlette.testclient
- typing
Source
Frequently Asked Questions
What does test_serialize_response_model.py do?
test_serialize_response_model.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_serialize_response_model.py?
test_serialize_response_model.py defines 16 function(s): get_coerce, get_coerce_exclude_unset, get_valid, get_valid_exclude_unset, get_validdict, get_validdict_exclude_unset, get_validlist, get_validlist_exclude_unset, test_coerce, test_coerce_exclude_unset, and 6 more.
What does test_serialize_response_model.py depend on?
test_serialize_response_model.py imports 4 module(s): __init__.py, pydantic, starlette.testclient, typing.
Where is test_serialize_response_model.py in the architecture?
test_serialize_response_model.py is located at tests/test_serialize_response_model.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