From df5a735b42aaf906ef6774fc2472ab8c06744420 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 09:41:22 +0000 Subject: [PATCH] Add Meal schema --- schemas/meal.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/schemas/meal.py b/schemas/meal.py index 1cc71e0..d3fa702 100644 --- a/schemas/meal.py +++ b/schemas/meal.py @@ -1,18 +1,33 @@ -from pydantic import BaseModel, Field -from typing import Optional -from uuid import UUID +from pydantic import BaseModel, Field, validator +from typing import Optional, Union class MealBase(BaseModel): name: str = Field(..., description="Name of the meal") description: Optional[str] = Field(None, description="Description of the meal") price: float = Field(..., gt=0, description="Price of the meal") - category_id: UUID = Field(..., description="ID of the category the meal belongs to") + is_available: bool = Field(True, description="Availability status of the meal") + category: Optional[str] = Field(None, description="Category of the meal") + cuisine: Optional[str] = Field(None, description="Cuisine of the meal") + dietary_restrictions: Optional[dict] = Field(None, description="Dietary restrictions for the meal") + + class Config: + schema_extra = { + "example": { + "name": "Margherita Pizza", + "description": "Classic Italian pizza with tomato sauce, mozzarella cheese, and fresh basil", + "price": 12.99, + "is_available": True, + "category": "Pizza", + "cuisine": "Italian", + "dietary_restrictions": {"vegetarian": True, "nut_free": True} + } + } class MealCreate(MealBase): pass class MealResponse(MealBase): - id: UUID = Field(..., description="ID of the meal") + id: int = Field(..., description="Unique identifier for the meal") class Config: orm_mode = True \ No newline at end of file