2025-03-28 09:45:09 +00:00

31 lines
1023 B
Python

from pydantic import BaseModel, Field
from typing import Optional
from uuid import UUID
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")
category_id: UUID = Field(..., description="ID of the category the food item belongs to")
class FoodCreate(FoodBase):
pass
class FoodResponse(FoodBase):
id: UUID
name: str
description: Optional[str]
price: float
category_id: UUID
class Config:
orm_mode = True
schema_extra = {
"example": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Pizza Margherita",
"description": "Classic Italian pizza with tomato sauce and mozzarella cheese",
"price": 12.99,
"category_id": "c6fc032f-d8c9-4b9b-8e3f-a1d0011e7c3c"
}
}