25 lines
804 B
Python
25 lines
804 B
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
import uuid
|
|
|
|
class BananaBase(BaseModel):
|
|
name: str = Field(..., description="Name of the banana")
|
|
description: Optional[str] = Field(None, description="Description of the banana")
|
|
quantity: int = Field(..., description="Quantity of bananas")
|
|
|
|
class BananaCreate(BananaBase):
|
|
pass
|
|
|
|
class BananaUpdate(BananaBase):
|
|
name: Optional[str] = Field(None, description="Name of the banana")
|
|
description: Optional[str] = Field(None, description="Description of the banana")
|
|
quantity: Optional[int] = Field(None, description="Quantity of bananas")
|
|
|
|
class BananaSchema(BananaBase):
|
|
id: uuid.UUID
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True |