2025-03-28 15:56:53 +00:00

28 lines
1.2 KiB
Python

from pydantic import BaseModel, Field
from typing import Optional, Union
class FoodBase(BaseModel):
name: str = 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")
is_available: bool = Field(True, description="Availability status of the food item")
category: Optional[str] = Field(None, description="Category of the food item")
cuisine: Optional[str] = Field(None, description="Cuisine of the food item")
allergens: Optional[Union[list, dict]] = Field(None, description="Allergens present in the food item")
class FoodCreate(FoodBase):
pass
class FoodResponse(FoodBase):
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",
"allergens": ["dairy", "wheat"]
}
}