From 15e8315b0a978b1d33f564ea53ae0c8a61558bee Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 14:45:40 +0000 Subject: [PATCH] Add Food schema --- schemas/food.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 schemas/food.py diff --git a/schemas/food.py b/schemas/food.py new file mode 100644 index 0000000..474589e --- /dev/null +++ b/schemas/food.py @@ -0,0 +1,37 @@ +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 \ No newline at end of file