
- Added pydantic and pydantic-settings to requirements.txt - Updated config.py to use proper Pydantic v2 imports and patterns - Updated schemas to use Pydantic v2 configuration format - Replaced orm_mode with from_attributes=True in schema models - Applied code formatting with Ruff
40 lines
799 B
Python
40 lines
799 B
Python
from datetime import datetime
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class FileBase(BaseModel):
|
|
"""Base schema for File with common attributes."""
|
|
|
|
filename: str
|
|
content_type: str
|
|
file_size: int
|
|
|
|
|
|
class FileCreate(FileBase):
|
|
"""Schema for creating a file (internal use)."""
|
|
|
|
original_filename: str
|
|
file_path: str
|
|
|
|
|
|
class FileInDB(FileBase):
|
|
"""Schema for file as stored in the database."""
|
|
|
|
id: int
|
|
original_filename: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class FileResponse(FileBase):
|
|
"""Schema for file response returned to clients."""
|
|
|
|
id: int
|
|
original_filename: str
|
|
created_at: datetime
|
|
download_url: str
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|