from pydantic import BaseModel, Field from typing import Optional from datetime import datetime from uuid import UUID class FoodBase(BaseModel): name: str = Field(..., min_length=1, max_length=100, description="Name of the food item") description: Optional[str] = Field(None, description="Detailed description of the food item") price: float = Field(..., gt=0, description="Price of the food item") category: str = Field(..., min_length=1, max_length=50, description="Category of the food item") is_available: bool = Field(default=True, description="Availability status of the food item") calories: Optional[int] = Field(None, ge=0, description="Caloric content of the food item") ingredients: Optional[str] = Field(None, description="List of ingredients") image_url: Optional[str] = Field(None, description="URL to the food item's image") class FoodCreate(FoodBase): class Config: schema_extra = { "example": { "name": "Margherita Pizza", "description": "Classic Italian pizza with tomato sauce and mozzarella", "price": 12.99, "category": "Pizza", "is_available": True, "calories": 266, "ingredients": "Dough, Tomato Sauce, Mozzarella, Basil", "image_url": "https://example.com/pizza.jpg" } } class Food(FoodBase): id: UUID created_at: datetime updated_at: datetime class Config: orm_mode = True