From dffe7e656b29c099dfd61f131b1c5a0a1e564400 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 19:26:54 +0000 Subject: [PATCH] Add User schema --- schemas/user.py | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/schemas/user.py b/schemas/user.py index 85f219f..bb92a11 100644 --- a/schemas/user.py +++ b/schemas/user.py @@ -1,46 +1,28 @@ -from pydantic import BaseModel, Field, EmailStr +from pydantic import BaseModel, Field from typing import Optional -from datetime import datetime class UserBase(BaseModel): - username: str = Field(..., min_length=3, max_length=50) - email: EmailStr = Field(..., max_length=100) - first_name: str = Field(..., max_length=50) - last_name: str = Field(..., max_length=50) + username: str = Field(..., min_length=1, max_length=50) class UserCreate(UserBase): - password: str = Field(..., min_length=8, max_length=255) - + password: str = Field(..., min_length=8, max_length=100) + class Config: schema_extra = { "example": { "username": "johndoe", - "email": "john@example.com", - "first_name": "John", - "last_name": "Doe", - "password": "securepassword123" + "password": "securepass123" } } class UserResponse(UserBase): - is_active: bool = True - is_verified: bool = False - is_superuser: bool = False - last_login: Optional[datetime] = None - refresh_token: Optional[str] = Field(None, max_length=255) - + id: int + class Config: orm_mode = True schema_extra = { "example": { - "username": "johndoe", - "email": "john@example.com", - "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" + "id": 1, + "username": "johndoe" } } \ No newline at end of file