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(...) first_name: Optional[str] = Field(None, max_length=50) last_name: Optional[str] = Field(None, max_length=50) bio: Optional[str] = Field(None, max_length=500) profile_picture: Optional[str] = Field(None) relationship_status: Optional[str] = Field(None) interests: Optional[str] = Field(None, max_length=500) is_active: bool = Field(default=True) class UserCreate(UserBase): password: str = Field(..., min_length=8, max_length=100) class Config: schema_extra = { "example": { "username": "johndoe", "email": "john@example.com", "password": "securepass123", "first_name": "John", "last_name": "Doe", "bio": "Hello, I'm John!", "profile_picture": "https://example.com/picture.jpg", "relationship_status": "single", "interests": "Reading, hiking, photography" } } class UserResponse(UserBase): id: int last_login: Optional[datetime] created_at: datetime updated_at: datetime class Config: orm_mode = True schema_extra = { "example": { "id": 1, "username": "johndoe", "email": "john@example.com", "first_name": "John", "last_name": "Doe", "bio": "Hello, I'm John!", "profile_picture": "https://example.com/picture.jpg", "relationship_status": "single", "interests": "Reading, hiking, photography", "is_active": True, "last_login": "2023-01-01T12:00:00", "created_at": "2023-01-01T10:00:00", "updated_at": "2023-01-01T10:00:00" } }