Files
app-service/backend/app/schemas/auth.py
2025-12-05 09:53:16 +01:00

42 lines
1.0 KiB
Python

"""Pydantic schemas for authentication requests/responses."""
from typing import Optional
from pydantic import BaseModel, Field, EmailStr
class Token(BaseModel):
"""JWT token response schema."""
access_token: str
token_type: str = "bearer"
class TokenData(BaseModel):
"""Token payload data schema."""
user_id: Optional[str] = None
class LoginRequest(BaseModel):
"""Login request schema."""
username: str = Field(..., min_length=3, max_length=100)
password: str = Field(..., min_length=1)
class RegisterRequest(BaseModel):
"""Registration request schema."""
username: str = Field(..., min_length=3, max_length=100)
email: EmailStr = Field(..., description="Valid email address")
password: str = Field(..., min_length=8, description="Password must be at least 8 characters")
class Config:
json_schema_extra = {
"example": {
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword123"
}
}