forked from mts-ai/FastAPI-JSONAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
33 lines (24 loc) · 879 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""JSON API utils package."""
from pathlib import Path
from fastapi import FastAPI
from fastapi_jsonapi.api import RoutersJSONAPI
from fastapi_jsonapi.exceptions import BadRequest
from fastapi_jsonapi.exceptions.handlers import base_exception_handler
from fastapi_jsonapi.exceptions.json_api import HTTPException
from fastapi_jsonapi.querystring import QueryStringManager
__version__ = Path(__file__).parent.joinpath("VERSION").read_text().strip()
__all__ = [
"init",
"BadRequest",
"QueryStringManager",
"RoutersJSONAPI",
]
def init(app: FastAPI):
"""
Init the app.
Processes the application by setting the entities necessary for work.
Action list:
- Registers default exception handlers for exceptions defined
in "fastapi_jsonapi.exceptions" module.
"""
app.add_exception_handler(HTTPException, base_exception_handler)