Add Food schema
This commit is contained in:
parent
b07d9cb142
commit
ecb161828d
31
schemas/food.py
Normal file
31
schemas/food.py
Normal file
@ -0,0 +1,31 @@
|
||||
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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user