from fastapi import Request from fastapi.exceptions import RequestValidationError from fastapi.responses import ORJSONResponse async def validation_exception_handler(_request: Request, exc: RequestValidationError) -> ORJSONResponse: return ORJSONResponse( status_code=422, content={'detail': exc.errors()}, )