tutorial002_py39.py — fastapi Source File
Architecture documentation for tutorial002_py39.py, a python file in the fastapi codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8["tutorial002_py39.py"] 0dda2280_3359_8460_301c_e98c77e78185["typing"] 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8 --> 0dda2280_3359_8460_301c_e98c77e78185 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 01c652c5_d85c_f45e_848e_412c94ea4172["exceptions.py"] 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8 --> 01c652c5_d85c_f45e_848e_412c94ea4172 58bb043a_10d8_c308_5564_225558a63815["RequestValidationError"] 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8 --> 58bb043a_10d8_c308_5564_225558a63815 de395a51_26f8_3424_1af0_2f5bef39c893["routing.py"] 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8 --> de395a51_26f8_3424_1af0_2f5bef39c893 aa28685f_bb97_e988_ff40_3e5385960f32["APIRoute"] 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8 --> aa28685f_bb97_e988_ff40_3e5385960f32 style 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Callable
from fastapi import Body, FastAPI, HTTPException, Request, Response
from fastapi.exceptions import RequestValidationError
from fastapi.routing import APIRoute
class ValidationErrorLoggingRoute(APIRoute):
def get_route_handler(self) -> Callable:
original_route_handler = super().get_route_handler()
async def custom_route_handler(request: Request) -> Response:
try:
return await original_route_handler(request)
except RequestValidationError as exc:
body = await request.body()
detail = {"errors": exc.errors(), "body": body.decode()}
raise HTTPException(status_code=422, detail=detail)
return custom_route_handler
app = FastAPI()
app.router.route_class = ValidationErrorLoggingRoute
@app.post("/")
async def sum_numbers(numbers: list[int] = Body()):
return sum(numbers)
Domain
Subdomains
Functions
Classes
Dependencies
Source
Frequently Asked Questions
What does tutorial002_py39.py do?
tutorial002_py39.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 tutorial002_py39.py?
tutorial002_py39.py defines 1 function(s): sum_numbers.
What does tutorial002_py39.py depend on?
tutorial002_py39.py imports 6 module(s): APIRoute, RequestValidationError, __init__.py, exceptions.py, routing.py, typing.
Where is tutorial002_py39.py in the architecture?
tutorial002_py39.py is located at docs_src/custom_request_and_route/tutorial002_py39.py (domain: FastAPI, subdomain: Responses, directory: docs_src/custom_request_and_route).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free