diff --git a/backend/main.py b/backend/main.py index 5a652f4..f0d1d4d 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,7 +1,7 @@ from fastapi import FastAPI, HTTPException, Header, Depends from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import RedirectResponse -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, ConfigDict from typing import List, Optional from datetime import datetime from sqlalchemy.orm import Session @@ -46,31 +46,31 @@ app.add_middleware( # Pydantic Models for API class UserResponse(BaseModel): + model_config = ConfigDict(from_attributes=True) + id: str username: str email: str created_at: datetime - class Config: - from_attributes = True - class UserRegister(BaseModel): username: str email: str password: str class UserLogin(BaseModel): + model_config = ConfigDict(populate_by_name=True) + username_or_email: str = Field(..., alias='usernameOrEmail') password: str - - class Config: - populate_by_name = True class AuthResponse(BaseModel): user: UserResponse token: str class TaskListResponse(BaseModel): + model_config = ConfigDict(from_attributes=True) + id: str user_id: str name: str @@ -78,9 +78,6 @@ class TaskListResponse(BaseModel): color: str = "#667eea" created_at: datetime - class Config: - from_attributes = True - class TaskListCreate(BaseModel): name: str icon: Optional[str] = "📝" @@ -92,6 +89,8 @@ class TaskListUpdate(BaseModel): color: Optional[str] = None class TaskResponse(BaseModel): + model_config = ConfigDict(from_attributes=True) + id: str list_id: str user_id: str @@ -102,9 +101,6 @@ class TaskResponse(BaseModel): created_at: datetime updated_at: datetime - class Config: - from_attributes = True - class TaskCreate(BaseModel): title: str list_id: str