mirror of
https://github.com/d3vyce/fastapi-toolsets.git
synced 2026-04-16 14:46:24 +02:00
refactor: remove deprecated parameter and function/cleanup code (#101)
* refactor: remove deprecated parameter and function * refactor: centralize type aliases in types.py and simplify crud layer * test: add missing tests for fixtures/utils.py * refactor: simplify and deduplicate across crud, metrics, cli, and exceptions * docs: fix old Paginate references * docs: add migration + fix icon * docs: update README/migration to v2
This commit is contained in:
@@ -14,6 +14,10 @@ from fastapi.responses import JSONResponse
|
||||
from ..schemas import ErrorResponse, ResponseStatus
|
||||
from .exceptions import ApiException
|
||||
|
||||
_VALIDATION_LOCATION_PARAMS: frozenset[str] = frozenset(
|
||||
{"body", "query", "path", "header", "cookie"}
|
||||
)
|
||||
|
||||
|
||||
def init_exceptions_handlers(app: FastAPI) -> FastAPI:
|
||||
"""Register exception handlers and custom OpenAPI schema on a FastAPI app.
|
||||
@@ -99,7 +103,7 @@ def _format_validation_error(
|
||||
|
||||
for error in errors:
|
||||
locs = error["loc"]
|
||||
if locs and locs[0] in ("body", "query", "path", "header", "cookie"):
|
||||
if locs and locs[0] in _VALIDATION_LOCATION_PARAMS:
|
||||
locs = locs[1:]
|
||||
field_path = ".".join(str(loc) for loc in locs)
|
||||
formatted_errors.append(
|
||||
|
||||
Reference in New Issue
Block a user