Api: init response envelop

This commit is contained in:
Johannes Kirschbauer
2024-05-26 15:57:10 +02:00
parent daa0be20de
commit 5e266578ae
2 changed files with 34 additions and 2 deletions

View File

@@ -1,9 +1,27 @@
from collections.abc import Callable
from typing import Any, TypeVar
from dataclasses import dataclass
from typing import Any, Generic, Literal, TypeVar
T = TypeVar("T")
ResponseDataType = TypeVar("ResponseDataType")
@dataclass
class ApiError:
message: str
description: str | None
location: list[str] | None
@dataclass
class ApiResponse(Generic[ResponseDataType]):
status: Literal["success", "error"]
errors: list[ApiError] | None
data: ResponseDataType | None
class _MethodRegistry:
def __init__(self) -> None:
self._registry: dict[str, Callable] = {}