2025-05-30 20:35:55 +00:00

55 lines
1.4 KiB
Python

"""
User schemas for the application
"""
from datetime import datetime
from typing import Optional
from pydantic import EmailStr
from app.schemas.base import BaseSchema, TimestampSchema
# Shared properties
class UserBase(BaseSchema):
"""Base user schema with shared properties"""
email: Optional[EmailStr] = None
username: Optional[str] = None
is_active: Optional[bool] = True
is_superuser: bool = False
first_name: Optional[str] = None
last_name: Optional[str] = None
target_calories: Optional[float] = 2000.0
height_cm: Optional[float] = None
weight_kg: Optional[float] = None
date_of_birth: Optional[datetime] = None
gender: Optional[str] = None
# Properties to receive via API on creation
class UserCreate(UserBase):
"""Schema for creating a new user"""
email: EmailStr
username: str
password: str
# Properties to receive via API on update
class UserUpdate(UserBase):
"""Schema for updating a user"""
password: Optional[str] = None
class UserInDBBase(UserBase, TimestampSchema):
"""Base schema for user in database"""
id: int
# Additional properties to return via API
class User(UserInDBBase):
"""Schema for returning a user via API"""
pass
# Additional properties stored in DB but not returned by API
class UserInDB(UserInDBBase):
"""Schema for user in database with hashed password"""
hashed_password: str