Add User schema
This commit is contained in:
parent
bfc7306d64
commit
18db952c7f
38
schemas/user.py
Normal file
38
schemas/user.py
Normal file
@ -0,0 +1,38 @@
|
||||
from pydantic import BaseModel, Field, EmailStr
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
class UserBase(BaseModel):
|
||||
username: str = Field(..., min_length=3, max_length=50)
|
||||
email: EmailStr = Field(...)
|
||||
|
||||
class UserCreate(UserBase):
|
||||
password: str = Field(..., min_length=8, max_length=100)
|
||||
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"username": "johndoe",
|
||||
"email": "john@example.com",
|
||||
"password": "securepass123"
|
||||
}
|
||||
}
|
||||
|
||||
class UserResponse(UserBase):
|
||||
is_active: bool = True
|
||||
is_logged_in: bool = False
|
||||
last_logout: Optional[datetime] = None
|
||||
session_token: Optional[str] = None
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"username": "johndoe",
|
||||
"email": "john@example.com",
|
||||
"is_active": True,
|
||||
"is_logged_in": False,
|
||||
"last_logout": "2023-01-01T00:00:00",
|
||||
"session_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user