Home / File/ tutorial003_py310.py — fastapi Source File

tutorial003_py310.py — fastapi Source File

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

File python FastAPI Responses 3 imports 2 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  94a7f88a_1a06_29e1_79b6_9c9eaa36af99["tutorial003_py310.py"]
  4cff5a35_9399_b238_3d2b_e2cca82878e1["dataclasses"]
  94a7f88a_1a06_29e1_79b6_9c9eaa36af99 --> 4cff5a35_9399_b238_3d2b_e2cca82878e1
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  94a7f88a_1a06_29e1_79b6_9c9eaa36af99 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a913f820_c954_4542_736a_45cc1a22c6fd["pydantic.dataclasses"]
  94a7f88a_1a06_29e1_79b6_9c9eaa36af99 --> a913f820_c954_4542_736a_45cc1a22c6fd
  style 94a7f88a_1a06_29e1_79b6_9c9eaa36af99 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from dataclasses import field  # (1)

from fastapi import FastAPI
from pydantic.dataclasses import dataclass  # (2)


@dataclass
class Item:
    name: str
    description: str | None = None


@dataclass
class Author:
    name: str
    items: list[Item] = field(default_factory=list)  # (3)


app = FastAPI()


@app.post("/authors/{author_id}/items/", response_model=Author)  # (4)
async def create_author_items(author_id: str, items: list[Item]):  # (5)
    return {"name": author_id, "items": items}  # (6)


@app.get("/authors/", response_model=list[Author])  # (7)
def get_authors():  # (8)
    return [  # (9)
        {
            "name": "Breaters",
            "items": [
                {
                    "name": "Island In The Moon",
                    "description": "A place to be playin' and havin' fun",
                },
                {"name": "Holy Buddies"},
            ],
        },
        {
            "name": "System of an Up",
            "items": [
                {
                    "name": "Salt",
                    "description": "The kombucha mushroom people's favorite",
                },
                {"name": "Pad Thai"},
                {
                    "name": "Lonely Night",
                    "description": "The mostests lonliest nightiest of allest",
                },
            ],
        },
    ]

Domain

Subdomains

Classes

Dependencies

Frequently Asked Questions

What does tutorial003_py310.py do?
tutorial003_py310.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 tutorial003_py310.py?
tutorial003_py310.py defines 2 function(s): create_author_items, get_authors.
What does tutorial003_py310.py depend on?
tutorial003_py310.py imports 3 module(s): __init__.py, dataclasses, pydantic.dataclasses.
Where is tutorial003_py310.py in the architecture?
tutorial003_py310.py is located at docs_src/dataclasses_/tutorial003_py310.py (domain: FastAPI, subdomain: Responses, directory: docs_src/dataclasses_).

Analyze Your Own Codebase

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

Try Supermodel Free