Automated Action f207cc3c64 Create RESTful API service with FastAPI and SQLite
- Set up project structure with FastAPI and dependency files
- Configure SQLAlchemy with SQLite database
- Implement user authentication using JWT tokens
- Create comprehensive API routes for user management
- Add health check endpoint for application monitoring
- Set up Alembic for database migrations
- Add detailed documentation in README.md
2025-06-16 14:56:03 +00:00

62 lines
1.1 KiB
Python

from pydantic import BaseModel, EmailStr, Field
from typing import Optional
from datetime import datetime
class UserBase(BaseModel):
"""
Base schema with common user attributes.
"""
email: EmailStr
full_name: Optional[str] = None
is_active: Optional[bool] = True
class UserCreate(UserBase):
"""
Schema for creating a new user, includes password.
"""
password: str = Field(..., min_length=8)
class UserUpdate(BaseModel):
"""
Schema for updating an existing user.
"""
email: Optional[EmailStr] = None
full_name: Optional[str] = None
password: Optional[str] = Field(None, min_length=8)
is_active: Optional[bool] = None
class UserInDBBase(UserBase):
"""
Base schema for user data from the database.
"""
id: int
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
class User(UserInDBBase):
"""
Schema for user data to return to client.
"""
pass
class UserInDB(UserInDBBase):
"""
Schema for user data with hashed_password field.
"""
hashed_password: str