49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
from datetime import datetime
|
|
from typing import TYPE_CHECKING
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
if TYPE_CHECKING:
|
|
from app.schemas.manga import Manga
|
|
|
|
|
|
# Shared properties
|
|
class AuthorBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=100, description="Name of the author")
|
|
biography: str | None = Field(None, description="Author's biography")
|
|
|
|
|
|
# Properties to receive on author creation
|
|
class AuthorCreate(AuthorBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on author update
|
|
class AuthorUpdate(AuthorBase):
|
|
name: str | None = Field(None, min_length=1, max_length=100, description="Name of the author")
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class AuthorInDBBase(AuthorBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Author(AuthorInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class AuthorInDB(AuthorInDBBase):
|
|
pass
|
|
|
|
|
|
# Additional properties for response with manga list
|
|
class AuthorWithManga(Author):
|
|
manga_list: list["Manga"] = []
|