from datetime import datetime from typing import Optional from pydantic import BaseModel # Shared properties class CategoryBase(BaseModel): """ Base schema for category data. """ name: Optional[str] = None description: Optional[str] = None # Properties to receive via API on creation class CategoryCreate(CategoryBase): """ Schema for creating new categories. """ name: str # Properties to receive via API on update class CategoryUpdate(CategoryBase): """ Schema for updating category data. """ pass class CategoryInDBBase(CategoryBase): """ Base schema for category data from the database. """ id: str created_at: datetime updated_at: datetime class Config: from_attributes = True # Additional properties to return via API class Category(CategoryInDBBase): """ Schema for category data to return via API. """ pass