Add Food schema
This commit is contained in:
parent
9cfa9c9d61
commit
88d312a3e3
34
schemas/food.py
Normal file
34
schemas/food.py
Normal file
@ -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
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user