Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import enum
from typing import Generic, TypeVar
from pydantic.generics import GenericModel
from pydantic import Field
T = TypeVar("T")
class ApiStatus(enum):
SUCCESS = 1
FAILURE = 0
class PaginatedContent(GenericModel, Generic[T]):
""" Content data type for lists with pagination"""
data: T
total_count: int = 0
limit: int = 100
offset: int = 0
class ApiResponseHeader(GenericModel, Generic[T]):
""" Header type of APIResponseType"""
status: int = Field(..., description=str(list(ApiStatus)))
message: str = "Success"
persian_message: str = "ﻊﻤﻟیﺎﺗ ﻡﻮﻔﻗ"
class APIResponseType(GenericModel, Generic[T]):
"""
an api response type for using as the api's router response_model
"""
header: ApiResponseHeader
content: T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment