tutorial015_an_py310.py — fastapi Source File
Architecture documentation for tutorial015_an_py310.py, a python file in the fastapi codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 98435e8a_7042_b057_13ea_1f22b38e3438["tutorial015_an_py310.py"] de7ad334_ca8a_57df_c9b1_c007a1804821["random"] 98435e8a_7042_b057_13ea_1f22b38e3438 --> de7ad334_ca8a_57df_c9b1_c007a1804821 0dda2280_3359_8460_301c_e98c77e78185["typing"] 98435e8a_7042_b057_13ea_1f22b38e3438 --> 0dda2280_3359_8460_301c_e98c77e78185 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 98435e8a_7042_b057_13ea_1f22b38e3438 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"] 98435e8a_7042_b057_13ea_1f22b38e3438 --> 6913fbd4_39df_d14b_44bb_522e99b65b90 style 98435e8a_7042_b057_13ea_1f22b38e3438 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import random
from typing import Annotated
from fastapi import FastAPI
from pydantic import AfterValidator
app = FastAPI()
data = {
"isbn-9781529046137": "The Hitchhiker's Guide to the Galaxy",
"imdb-tt0371724": "The Hitchhiker's Guide to the Galaxy",
"isbn-9781439512982": "Isaac Asimov: The Complete Stories, Vol. 2",
}
def check_valid_id(id: str):
if not id.startswith(("isbn-", "imdb-")):
raise ValueError('Invalid ID format, it must start with "isbn-" or "imdb-"')
return id
@app.get("/items/")
async def read_items(
id: Annotated[str | None, AfterValidator(check_valid_id)] = None,
):
if id:
item = data.get(id)
else:
id, item = random.choice(list(data.items()))
return {"id": id, "name": item}
Domain
Subdomains
Functions
Dependencies
- __init__.py
- pydantic
- random
- typing
Source
Frequently Asked Questions
What does tutorial015_an_py310.py do?
tutorial015_an_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 tutorial015_an_py310.py?
tutorial015_an_py310.py defines 2 function(s): check_valid_id, read_items.
What does tutorial015_an_py310.py depend on?
tutorial015_an_py310.py imports 4 module(s): __init__.py, pydantic, random, typing.
Where is tutorial015_an_py310.py in the architecture?
tutorial015_an_py310.py is located at docs_src/query_params_str_validations/tutorial015_an_py310.py (domain: FastAPI, subdomain: Responses, directory: docs_src/query_params_str_validations).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free