Add User schemas

This commit is contained in:
2026-01-26 21:56:10 +11:00
parent 742a9c9880
commit e74f5d717f

View File

@@ -0,0 +1,36 @@
"""User schemas."""
from pydantic import BaseModel, EmailStr
from datetime import datetime
from typing import Optional
class UserBase(BaseModel):
"""Base user schema."""
username: str
email: EmailStr
full_name: Optional[str] = None
class UserCreate(UserBase):
"""Schema for creating a user."""
password: str
class UserUpdate(BaseModel):
"""Schema for updating a user."""
email: Optional[EmailStr] = None
full_name: Optional[str] = None
password: Optional[str] = None
is_active: Optional[bool] = None
class UserResponse(UserBase):
"""Schema for user response."""
id: int
is_active: bool
is_admin: bool
created_at: datetime
class Config:
from_attributes = True
class UserLogin(BaseModel):
"""Schema for user login."""
username: str
password: str