Add User schema
This commit is contained in:
parent
4852ff3f12
commit
959de7403d
@ -1,34 +1,58 @@
|
||||
from pydantic import BaseModel, Field, EmailStr
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
class UserBase(BaseModel):
|
||||
name: str = Field(..., min_length=1, max_length=100, description="User's full name")
|
||||
address: str = Field(..., min_length=1, max_length=200, description="User's address")
|
||||
phone: Optional[str] = Field(None, max_length=20, description="User's phone number")
|
||||
email: EmailStr = Field(..., description="User's email address")
|
||||
is_active: bool = Field(default=True, description="User's active status")
|
||||
username: str = Field(..., min_length=3, max_length=50)
|
||||
email: EmailStr = Field(...)
|
||||
first_name: Optional[str] = Field(None, max_length=50)
|
||||
last_name: Optional[str] = Field(None, max_length=50)
|
||||
bio: Optional[str] = Field(None, max_length=500)
|
||||
profile_picture: Optional[str] = Field(None)
|
||||
relationship_status: Optional[str] = Field(None)
|
||||
interests: Optional[str] = Field(None, max_length=500)
|
||||
is_active: bool = Field(default=True)
|
||||
|
||||
class UserCreate(UserBase):
|
||||
password: str = Field(..., min_length=8, max_length=100)
|
||||
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"name": "John Doe",
|
||||
"address": "123 Main St, City, Country",
|
||||
"phone": "+1234567890",
|
||||
"username": "johndoe",
|
||||
"email": "john@example.com",
|
||||
"is_active": True
|
||||
"password": "securepass123",
|
||||
"first_name": "John",
|
||||
"last_name": "Doe",
|
||||
"bio": "Hello, I'm John!",
|
||||
"profile_picture": "https://example.com/picture.jpg",
|
||||
"relationship_status": "single",
|
||||
"interests": "Reading, hiking, photography"
|
||||
}
|
||||
}
|
||||
|
||||
class UserResponse(UserBase):
|
||||
id: int
|
||||
last_login: Optional[datetime]
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"name": "John Doe",
|
||||
"address": "123 Main St, City, Country",
|
||||
"phone": "+1234567890",
|
||||
"id": 1,
|
||||
"username": "johndoe",
|
||||
"email": "john@example.com",
|
||||
"is_active": True
|
||||
"first_name": "John",
|
||||
"last_name": "Doe",
|
||||
"bio": "Hello, I'm John!",
|
||||
"profile_picture": "https://example.com/picture.jpg",
|
||||
"relationship_status": "single",
|
||||
"interests": "Reading, hiking, photography",
|
||||
"is_active": True,
|
||||
"last_login": "2023-01-01T12:00:00",
|
||||
"created_at": "2023-01-01T10:00:00",
|
||||
"updated_at": "2023-01-01T10:00:00"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user