from typing import List, Optional from pydantic import BaseModel, Field class CategoryBase(BaseModel): """ Base category schema with common attributes. """ name: str = Field(..., description="Category name") description: Optional[str] = Field(None, description="Category description") class CategoryCreate(CategoryBase): """ Schema for category creation. """ pass class CategoryUpdate(BaseModel): """ Schema for updating category information. """ name: Optional[str] = Field(None, description="Category name") description: Optional[str] = Field(None, description="Category description") class CategoryInDBBase(CategoryBase): """ Base schema for categories from the database. """ id: int = Field(..., description="Category ID") class Config: from_attributes = True class Category(CategoryInDBBase): """ Schema for category information returned to clients. """ pass class CategoryWithItems(CategoryInDBBase): """ Schema for category with related items. """ from app.schemas.item import Item items: List[Item] = Field([], description="Items in this category")