28 lines
838 B
Python
28 lines
838 B
Python
import uuid
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
class FruitBase(BaseModel):
|
|
name: str = Field(..., description="Name of the fruit")
|
|
description: Optional[str] = Field(None, description="Description of the fruit")
|
|
price: int = Field(..., description="Price of the fruit")
|
|
|
|
class FruitCreate(FruitBase):
|
|
pass
|
|
|
|
class FruitUpdate(FruitBase):
|
|
name: Optional[str] = Field(None, description="Name of the fruit")
|
|
description: Optional[str] = Field(None, description="Description of the fruit")
|
|
price: Optional[int] = Field(None, description="Price of the fruit")
|
|
|
|
class FruitResponse(BaseModel):
|
|
data: FruitBase
|
|
|
|
class FruitSchema(FruitBase):
|
|
id: uuid.UUID
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True |