23 lines
534 B
Python
23 lines
534 B
Python
"""认证相关的请求/响应 schema。"""
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class RegisterRequest(BaseModel):
|
|
username: str = Field(min_length=3, max_length=64)
|
|
password: str = Field(min_length=6, max_length=128)
|
|
email: str | None = Field(default=None, max_length=255)
|
|
|
|
|
|
class Token(BaseModel):
|
|
access_token: str
|
|
token_type: str = "bearer"
|
|
|
|
|
|
class UserOut(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: str
|
|
username: str
|
|
email: str | None
|
|
is_active: bool
|