test_serialize_response_dataclass.py — fastapi Source File
Architecture documentation for test_serialize_response_dataclass.py, a python file in the fastapi codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR cc2e05a7_3368_3936_0f86_18c75f23ff0c["test_serialize_response_dataclass.py"] 4cff5a35_9399_b238_3d2b_e2cca82878e1["dataclasses"] cc2e05a7_3368_3936_0f86_18c75f23ff0c --> 4cff5a35_9399_b238_3d2b_e2cca82878e1 e973e384_8276_b242_eb98_1c0b79a84e68["datetime"] cc2e05a7_3368_3936_0f86_18c75f23ff0c --> e973e384_8276_b242_eb98_1c0b79a84e68 0dda2280_3359_8460_301c_e98c77e78185["typing"] cc2e05a7_3368_3936_0f86_18c75f23ff0c --> 0dda2280_3359_8460_301c_e98c77e78185 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] cc2e05a7_3368_3936_0f86_18c75f23ff0c --> 534f6e44_61b8_3c38_8b89_6934a6df9802 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] cc2e05a7_3368_3936_0f86_18c75f23ff0c --> a7c04dee_ee23_5891_b185_47ff6bed036d style cc2e05a7_3368_3936_0f86_18c75f23ff0c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from dataclasses import dataclass
from datetime import datetime
from typing import Optional
from fastapi import FastAPI
from fastapi.testclient import TestClient
app = FastAPI()
@dataclass
class Item:
name: str
date: datetime
price: Optional[float] = None
owner_ids: Optional[list[int]] = None
@app.get("/items/valid", response_model=Item)
def get_valid():
return {"name": "valid", "date": datetime(2021, 7, 26), "price": 1.0}
@app.get("/items/object", response_model=Item)
def get_object():
return Item(
name="object", date=datetime(2021, 7, 26), price=1.0, owner_ids=[1, 2, 3]
)
@app.get("/items/coerce", response_model=Item)
def get_coerce():
return {"name": "coerce", "date": datetime(2021, 7, 26).isoformat(), "price": "1.0"}
@app.get("/items/validlist", response_model=list[Item])
def get_validlist():
return [
{"name": "foo", "date": datetime(2021, 7, 26)},
{"name": "bar", "date": datetime(2021, 7, 26), "price": 1.0},
{
"name": "baz",
"date": datetime(2021, 7, 26),
"price": 2.0,
"owner_ids": [1, 2, 3],
},
]
@app.get("/items/objectlist", response_model=list[Item])
def get_objectlist():
return [
Item(name="foo", date=datetime(2021, 7, 26)),
Item(name="bar", date=datetime(2021, 7, 26), price=1.0),
Item(name="baz", date=datetime(2021, 7, 26), price=2.0, owner_ids=[1, 2, 3]),
]
@app.get("/items/no-response-model/object")
def get_no_response_model_object():
// ... (135 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- __init__.py
- dataclasses
- datetime
- testclient.py
- typing
Source
Frequently Asked Questions
What does test_serialize_response_dataclass.py do?
test_serialize_response_dataclass.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in test_serialize_response_dataclass.py?
test_serialize_response_dataclass.py defines 14 function(s): get_coerce, get_no_response_model_object, get_no_response_model_objectlist, get_object, get_objectlist, get_valid, get_validlist, test_coerce, test_no_response_model_object, test_no_response_model_objectlist, and 4 more.
What does test_serialize_response_dataclass.py depend on?
test_serialize_response_dataclass.py imports 5 module(s): __init__.py, dataclasses, datetime, testclient.py, typing.
Where is test_serialize_response_dataclass.py in the architecture?
test_serialize_response_dataclass.py is located at tests/test_serialize_response_dataclass.py (domain: FastAPI, subdomain: Applications, directory: tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free