From 959de7403dd94a5299c186dfd7b072ec07d0d766 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 27 Mar 2025 21:49:33 +0000 Subject: [PATCH] Add User schema --- schemas/user.py | 50 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/schemas/user.py b/schemas/user.py index d435cd8..9626d37 100644 --- a/schemas/user.py +++ b/schemas/user.py @@ -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" } } \ No newline at end of file