"""API schemas for posts.""" from datetime import datetime from uuid import UUID from pydantic import BaseModel, ConfigDict, Field class PostBaseSchema(BaseModel): """Base schema for posts.""" model_config = ConfigDict(from_attributes=True) title: str = Field(..., min_length=3, max_length=200) content: str = Field(..., min_length=10, max_length=50000) class PostCreateSchema(PostBaseSchema): """Schema for creating a post.""" tags: list[str] = Field(default_factory=list) class PostUpdateSchema(BaseModel): """Schema for updating a post.""" model_config = ConfigDict(from_attributes=True) title: str | None = Field(None, min_length=3, max_length=200) content: str | None = Field(None, min_length=10, max_length=50000) tags: list[str] | None = None class PostResponseSchema(BaseModel): """Schema for post response.""" model_config = ConfigDict(from_attributes=True) id: UUID title: str content: str slug: str author_id: str published: bool tags: list[str] created_at: datetime updated_at: datetime class PostListResponseSchema(BaseModel): """Schema for list of posts response.""" items: list[PostResponseSchema] total: int class PostSearchSchema(BaseModel): """Schema for searching posts.""" query: str = Field(..., min_length=1, max_length=100) class PostPublishSchema(BaseModel): """Schema for publishing/unpublishing a post.""" published: bool