Skip to content

Instantly share code, notes, and snippets.

Last active July 18, 2022 08:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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):
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