from pydantic import BaseModel, Field from typing import Optional from datetime import datetime class ShoeBase(BaseModel): name: str = Field(..., index=True, min_length=1, max_length=100) brand: str = Field(..., min_length=1, max_length=50) size: int = Field(..., gt=0, lt=50) color: str = Field(..., min_length=1, max_length=30) style: Optional[str] = Field(None, max_length=50) condition: Optional[str] = Field(None, max_length=50) price: Optional[int] = Field(None, gt=0) notes: Optional[str] = Field(None, max_length=500) class ShoeCreate(ShoeBase): purchase_date: Optional[datetime] = None class Config: schema_extra = { "example": { "name": "Air Max 90", "brand": "Nike", "size": 42, "color": "White", "style": "Sneaker", "condition": "New", "purchase_date": "2023-01-01T00:00:00", "price": 129, "notes": "Limited edition colorway" } } class Shoe(ShoeBase): id: int purchase_date: Optional[datetime] created_at: datetime updated_at: datetime class Config: orm_mode = True schema_extra = { "example": { "id": 1, "name": "Air Max 90", "brand": "Nike", "size": 42, "color": "White", "style": "Sneaker", "condition": "New", "purchase_date": "2023-01-01T00:00:00", "price": 129, "notes": "Limited edition colorway", "created_at": "2023-01-01T00:00:00", "updated_at": "2023-01-01T00:00:00" } }