Add User schema
This commit is contained in:
parent
8c15ed59bc
commit
dffe7e656b
@ -1,46 +1,28 @@
|
|||||||
from pydantic import BaseModel, Field, EmailStr
|
from pydantic import BaseModel, Field
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
class UserBase(BaseModel):
|
class UserBase(BaseModel):
|
||||||
username: str = Field(..., min_length=3, max_length=50)
|
username: str = Field(..., min_length=1, max_length=50)
|
||||||
email: EmailStr = Field(..., max_length=100)
|
|
||||||
first_name: str = Field(..., max_length=50)
|
|
||||||
last_name: str = Field(..., max_length=50)
|
|
||||||
|
|
||||||
class UserCreate(UserBase):
|
class UserCreate(UserBase):
|
||||||
password: str = Field(..., min_length=8, max_length=255)
|
password: str = Field(..., min_length=8, max_length=100)
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
schema_extra = {
|
schema_extra = {
|
||||||
"example": {
|
"example": {
|
||||||
"username": "johndoe",
|
"username": "johndoe",
|
||||||
"email": "john@example.com",
|
"password": "securepass123"
|
||||||
"first_name": "John",
|
|
||||||
"last_name": "Doe",
|
|
||||||
"password": "securepassword123"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserResponse(UserBase):
|
class UserResponse(UserBase):
|
||||||
is_active: bool = True
|
id: int
|
||||||
is_verified: bool = False
|
|
||||||
is_superuser: bool = False
|
|
||||||
last_login: Optional[datetime] = None
|
|
||||||
refresh_token: Optional[str] = Field(None, max_length=255)
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
schema_extra = {
|
schema_extra = {
|
||||||
"example": {
|
"example": {
|
||||||
"username": "johndoe",
|
"id": 1,
|
||||||
"email": "john@example.com",
|
"username": "johndoe"
|
||||||
"first_name": "John",
|
|
||||||
"last_name": "Doe",
|
|
||||||
"is_active": True,
|
|
||||||
"is_verified": False,
|
|
||||||
"is_superuser": False,
|
|
||||||
"last_login": "2023-01-01T00:00:00",
|
|
||||||
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user