Add FoodMenu schema
This commit is contained in:
parent
47bfb52042
commit
115e4dba2f
53
schemas/foodmenu.py
Normal file
53
schemas/foodmenu.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import Optional
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
class FoodMenuBase(BaseModel):
|
||||||
|
name: str = Field(..., min_length=1, max_length=100, description="Name of the menu item")
|
||||||
|
description: Optional[str] = Field(None, max_length=500, description="Description of the menu item")
|
||||||
|
price: Decimal = Field(..., ge=0, decimal_places=2, max_digits=10, description="Price of the menu item")
|
||||||
|
category: str = Field(..., min_length=1, max_length=50, description="Category of the menu item")
|
||||||
|
is_available: bool = Field(default=True, description="Availability status of the menu item")
|
||||||
|
preparation_time: Optional[int] = Field(None, ge=0, description="Preparation time in minutes")
|
||||||
|
calories: Optional[int] = Field(None, ge=0, description="Caloric content")
|
||||||
|
ingredients: Optional[str] = Field(None, max_length=500, description="List of ingredients")
|
||||||
|
allergens: Optional[str] = Field(None, max_length=200, description="List of allergens")
|
||||||
|
image_url: Optional[str] = Field(None, max_length=255, description="URL of the menu item image")
|
||||||
|
|
||||||
|
class FoodMenuCreate(FoodMenuBase):
|
||||||
|
class Config:
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"name": "Margherita Pizza",
|
||||||
|
"description": "Classic Italian pizza with tomatoes and mozzarella",
|
||||||
|
"price": "12.99",
|
||||||
|
"category": "Pizza",
|
||||||
|
"is_available": True,
|
||||||
|
"preparation_time": 20,
|
||||||
|
"calories": 800,
|
||||||
|
"ingredients": "Dough, tomatoes, mozzarella, basil",
|
||||||
|
"allergens": "Gluten, dairy",
|
||||||
|
"image_url": "https://example.com/images/margherita.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FoodMenuResponse(FoodMenuBase):
|
||||||
|
id: int = Field(..., description="Unique identifier for the menu item")
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"id": 1,
|
||||||
|
"name": "Margherita Pizza",
|
||||||
|
"description": "Classic Italian pizza with tomatoes and mozzarella",
|
||||||
|
"price": "12.99",
|
||||||
|
"category": "Pizza",
|
||||||
|
"is_available": True,
|
||||||
|
"preparation_time": 20,
|
||||||
|
"calories": 800,
|
||||||
|
"ingredients": "Dough, tomatoes, mozzarella, basil",
|
||||||
|
"allergens": "Gluten, dairy",
|
||||||
|
"image_url": "https://example.com/images/margherita.jpg"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user