Add Food schema
This commit is contained in:
parent
81c3ea1c08
commit
73b8e11259
37
schemas/food.py
Normal file
37
schemas/food.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import Optional
|
||||||
|
from datetime import datetime
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
class FoodBase(BaseModel):
|
||||||
|
name: str = Field(..., min_length=1, max_length=100, description="Name of the food item")
|
||||||
|
description: Optional[str] = Field(None, description="Detailed description of the food item")
|
||||||
|
price: float = Field(..., gt=0, description="Price of the food item")
|
||||||
|
category: str = Field(..., min_length=1, max_length=50, description="Category of the food item")
|
||||||
|
is_available: bool = Field(default=True, description="Availability status of the food item")
|
||||||
|
calories: Optional[int] = Field(None, ge=0, description="Caloric content of the food item")
|
||||||
|
ingredients: Optional[str] = Field(None, description="List of ingredients")
|
||||||
|
image_url: Optional[str] = Field(None, description="URL of the food item image")
|
||||||
|
|
||||||
|
class FoodCreate(FoodBase):
|
||||||
|
class Config:
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"name": "Margherita Pizza",
|
||||||
|
"description": "Classic Italian pizza with tomato sauce and mozzarella",
|
||||||
|
"price": 12.99,
|
||||||
|
"category": "Pizza",
|
||||||
|
"is_available": True,
|
||||||
|
"calories": 266,
|
||||||
|
"ingredients": "Dough, Tomato Sauce, Mozzarella, Basil",
|
||||||
|
"image_url": "https://example.com/pizza.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Food(FoodBase):
|
||||||
|
id: UUID
|
||||||
|
created_at: datetime
|
||||||
|
updated_at: datetime
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
Loading…
x
Reference in New Issue
Block a user