54 lines
1.2 KiB
Python
54 lines
1.2 KiB
Python
"""
|
|
Item schema module.
|
|
"""
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ItemBase(BaseModel):
|
|
"""
|
|
Base schema for Item.
|
|
"""
|
|
name: str = Field(..., min_length=1, max_length=255, description="The name of the item")
|
|
description: Optional[str] = Field(None, description="The description of the item")
|
|
is_active: bool = Field(True, description="Whether the item is active")
|
|
|
|
|
|
class ItemCreate(ItemBase):
|
|
"""
|
|
Schema for creating an Item.
|
|
"""
|
|
pass
|
|
|
|
|
|
class ItemUpdate(BaseModel):
|
|
"""
|
|
Schema for updating an Item.
|
|
"""
|
|
name: Optional[str] = Field(None, min_length=1, max_length=255, description="The name of the item")
|
|
description: Optional[str] = Field(None, description="The description of the item")
|
|
is_active: Optional[bool] = Field(None, description="Whether the item is active")
|
|
|
|
|
|
class ItemInDBBase(ItemBase):
|
|
"""
|
|
Base schema for Item in DB.
|
|
"""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
"""
|
|
Pydantic config.
|
|
"""
|
|
orm_mode = True
|
|
from_attributes = True
|
|
|
|
|
|
class Item(ItemInDBBase):
|
|
"""
|
|
Schema for Item.
|
|
"""
|
|
pass |