Add Meal schema
This commit is contained in:
parent
5443b9e111
commit
0d925351fa
27
schemas/meal.py
Normal file
27
schemas/meal.py
Normal file
@ -0,0 +1,27 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
|
||||
# Base schema
|
||||
class MealBase(BaseModel):
|
||||
name: str = Field(..., index=True, description="Name of the meal")
|
||||
description: Optional[str] = Field(None, description="Description of the meal")
|
||||
price: float = Field(..., description="Price of the meal")
|
||||
category: Optional[str] = Field(None, index=True, description="Category of the meal")
|
||||
is_available: bool = Field(True, description="Availability status of the meal")
|
||||
|
||||
# Create schema
|
||||
class MealCreate(MealBase):
|
||||
pass
|
||||
|
||||
# Response schema
|
||||
class Meal(MealBase):
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"name": "Margherita Pizza",
|
||||
"description": "Classic Italian pizza with tomato sauce, mozzarella, and basil",
|
||||
"price": 9.99,
|
||||
"category": "Pizza",
|
||||
"is_available": True
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user