From 333373f75ea9ddbaf4e988b243450c264685e320 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 18:04:53 +0100 Subject: [PATCH] Add User schema --- schemas/user.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 schemas/user.py diff --git a/schemas/user.py b/schemas/user.py new file mode 100644 index 0000000..f409e7b --- /dev/null +++ b/schemas/user.py @@ -0,0 +1,26 @@ +from pydantic import BaseModel, Field, EmailStr + +class UserBase(BaseModel): + username: str = Field(..., min_length=3, max_length=50, index=True, unique=True, description="User's username") + email: EmailStr = Field(..., unique=True, description="User's email address") + password: str = Field(..., min_length=8, description="User's password") + is_active: bool = Field(True, description="Whether the user account is active") + + class Config: + schema_extra = { + "example": { + "username": "johndoe", + "email": "john@example.com", + "password": "securepassword123", + "is_active": True + } + } + +class UserCreate(UserBase): + pass + +class UserResponse(UserBase): + id: int = Field(..., description="User's unique identifier") + + class Config: + orm_mode = True \ No newline at end of file