from pydantic import BaseModel, Field from typing import Optional from datetime import datetime from uuid import UUID class GroceryItemBase(BaseModel): name: str = Field(..., description="Name of the grocery item") class GroceryItemCreate(GroceryItemBase): pass class GroceryItemUpdate(GroceryItemBase): name: Optional[str] = Field(None, description="Name of the grocery item") class GroceryItemSchema(GroceryItemBase): id: UUID created_at: datetime updated_at: datetime class Config: orm_mode = True schema_extra = { "example": { "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "name": "Milk", "created_at": "2023-01-01T12:00:00", "updated_at": "2023-01-01T12:00:00" } }