from pydantic import BaseModel, Field, EmailStr from typing import Optional from datetime import datetime class UserBase(BaseModel): username: str = Field(..., min_length=3, max_length=50) email: EmailStr = Field(...) company_name: Optional[str] = None role: str = Field(default="user") phone: Optional[str] = None address: Optional[str] = None is_active: bool = True account_balance: float = 0.0 class UserCreate(UserBase): password: str = Field(..., min_length=8) class Config: schema_extra = { "example": { "username": "johndoe", "email": "john@example.com", "password": "securepass123", "company_name": "Acme Corp", "role": "user", "phone": "+1234567890", "address": "123 Main St", "is_active": True, "account_balance": 0.0 } } class UserResponse(UserBase): id: int created_at: datetime updated_at: datetime class Config: orm_mode = True schema_extra = { "example": { "id": 1, "username": "johndoe", "email": "john@example.com", "company_name": "Acme Corp", "role": "user", "phone": "+1234567890", "address": "123 Main St", "is_active": True, "account_balance": 0.0, "created_at": "2023-01-01T00:00:00", "updated_at": "2023-01-01T00:00:00" } }