27 lines
900 B
Python
27 lines
900 B
Python
from pydantic import BaseModel, Field, EmailStr
|
|
|
|
class UserBase(BaseModel):
|
|
first_name: str = Field(..., description="User's first name")
|
|
last_name: str = Field(..., description="User's last name")
|
|
email: EmailStr = Field(..., description="User's email address")
|
|
is_active: bool = Field(True, description="Whether the user is active or not")
|
|
|
|
class UserCreate(UserBase):
|
|
password: str = Field(..., min_length=8, description="User's password")
|
|
|
|
class Config:
|
|
schema_extra = {
|
|
"example": {
|
|
"first_name": "John",
|
|
"last_name": "Doe",
|
|
"email": "john.doe@example.com",
|
|
"password": "securepassword123",
|
|
"is_active": True
|
|
}
|
|
}
|
|
|
|
class UserResponse(UserBase):
|
|
id: int = Field(..., description="User's unique identifier")
|
|
|
|
class Config:
|
|
orm_mode = True |