54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
"""
|
|
Tool_OCR - User Schemas
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel, EmailStr, Field
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
"""Base user schema"""
|
|
username: str = Field(..., min_length=3, max_length=50)
|
|
email: EmailStr
|
|
full_name: Optional[str] = Field(None, max_length=100)
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
"""User creation schema"""
|
|
password: str = Field(..., min_length=6, description="Password (min 6 characters)")
|
|
|
|
class Config:
|
|
json_schema_extra = {
|
|
"example": {
|
|
"username": "johndoe",
|
|
"email": "john@example.com",
|
|
"full_name": "John Doe",
|
|
"password": "secret123"
|
|
}
|
|
}
|
|
|
|
|
|
class UserResponse(UserBase):
|
|
"""User response schema"""
|
|
id: int
|
|
is_active: bool
|
|
is_admin: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
json_schema_extra = {
|
|
"example": {
|
|
"id": 1,
|
|
"username": "johndoe",
|
|
"email": "john@example.com",
|
|
"full_name": "John Doe",
|
|
"is_active": True,
|
|
"is_admin": False,
|
|
"created_at": "2025-01-01T00:00:00",
|
|
"updated_at": "2025-01-01T00:00:00"
|
|
}
|
|
}
|