from pydantic import BaseModel, Field from typing import Optional class UserBase(BaseModel): username: str = Field(..., min_length=1, max_length=50) class UserCreate(UserBase): password: str = Field(..., min_length=8, max_length=100) class Config: schema_extra = { "example": { "username": "johndoe", "password": "securepass123" } } class UserResponse(UserBase): id: int class Config: orm_mode = True schema_extra = { "example": { "id": 1, "username": "johndoe" } }