from pydantic import BaseModel, Field from typing import Optional from datetime import datetime from uuid import UUID class GroceryBase(BaseModel): name: str = Field(..., min_length=1, description="Name of the grocery item") color: Optional[str] = Field(None, description="Color of the grocery item") shape: Optional[str] = Field(None, description="Shape of the grocery item") class GroceryCreate(GroceryBase): pass class GroceryUpdate(BaseModel): name: Optional[str] = Field(None, min_length=1, description="Name of the grocery item") color: Optional[str] = Field(None, description="Color of the grocery item") shape: Optional[str] = Field(None, description="Shape of the grocery item") class GrocerySchema(GroceryBase): id: UUID created_at: datetime updated_at: datetime class Config: orm_mode = True schema_extra = { "example": { "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "name": "Milk", "color": "White", "shape": "Rectangular", "created_at": "2023-01-01T12:00:00", "updated_at": "2023-01-01T12:00:00" } }