33 lines
591 B
Python
33 lines
591 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from typing import Any, Generic, TypeAlias, TypeVar
|
||
|
|
|
||
|
|
from pydantic import BaseModel, ConfigDict
|
||
|
|
|
||
|
|
JsonValue: TypeAlias = Any
|
||
|
|
JsonObject: TypeAlias = dict[str, Any]
|
||
|
|
JsonList: TypeAlias = list[Any]
|
||
|
|
|
||
|
|
T = TypeVar('T')
|
||
|
|
|
||
|
|
|
||
|
|
class SchemaModel(BaseModel):
|
||
|
|
model_config = ConfigDict(extra='allow', populate_by_name=True)
|
||
|
|
|
||
|
|
|
||
|
|
class ApiEnvelope(SchemaModel, Generic[T]):
|
||
|
|
code: int
|
||
|
|
msg: str
|
||
|
|
data: T
|
||
|
|
|
||
|
|
|
||
|
|
class RouteContract(SchemaModel):
|
||
|
|
method: str
|
||
|
|
path: str
|
||
|
|
request_model: str
|
||
|
|
response_model: str
|
||
|
|
|
||
|
|
|
||
|
|
class EmptyRequest(SchemaModel):
|
||
|
|
pass
|