diff --git a/schemas/food.py b/schemas/food.py new file mode 100644 index 0000000..eab89ea --- /dev/null +++ b/schemas/food.py @@ -0,0 +1,34 @@ +from pydantic import BaseModel, Field, constr +from typing import Optional +from enum import Enum + +class FoodCategory(str, Enum): + APPETIZER = "appetizer" + MAIN_COURSE = "main_course" + DESSERT = "dessert" + BEVERAGE = "beverage" + +class FoodBase(BaseModel): + name: constr(min_length=1, max_length=100) = Field(..., description="Name of the food item") + description: Optional[str] = Field(None, description="Description of the food item") + price: float = Field(..., gt=0, description="Price of the food item") + category: FoodCategory = Field(..., description="Category of the food item") + +class FoodCreate(FoodBase): + pass + +class FoodResponse(FoodBase): + id: int = Field(..., description="Unique identifier for the food item") + is_available: bool = Field(True, description="Availability status of the food item") + + class Config: + schema_extra = { + "example": { + "id": 1, + "name": "Margherita Pizza", + "description": "Classic Italian pizza with tomato sauce, mozzarella, and fresh basil", + "price": 12.99, + "category": "main_course", + "is_available": True + } + } \ No newline at end of file