from datetime import datetime from typing import Optional, List from pydantic import BaseModel from app.schemas.user import User from app.schemas.tag import Tag # Shared properties class PostBase(BaseModel): title: Optional[str] = None content: Optional[str] = None published: Optional[bool] = True # Properties to receive via API on creation class PostCreate(PostBase): title: str content: str tag_ids: Optional[List[int]] = [] # Properties to receive via API on update class PostUpdate(PostBase): tag_ids: Optional[List[int]] = None # Properties shared by models stored in DB class PostInDBBase(PostBase): id: int title: str content: str author_id: int created_at: datetime updated_at: datetime class Config: from_attributes = True # Properties to return to client class Post(PostInDBBase): author: User tags: List[Tag] = [] # Properties stored in DB class PostInDB(PostInDBBase): pass