Add User schema
This commit is contained in:
parent
f55cadcbf4
commit
887b63b40e
27
schemas/user.py
Normal file
27
schemas/user.py
Normal file
@ -0,0 +1,27 @@
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user