Automated Action 07301a47e7 Implement RESTful API using FastAPI and SQLite
- Set up project structure with FastAPI framework
- Implement database models using SQLAlchemy
- Create Alembic migrations for database schema
- Build CRUD endpoints for Items resource
- Add health check endpoint
- Include API documentation with Swagger and ReDoc
- Update README with project documentation
2025-05-18 16:46:51 +00:00

40 lines
807 B
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field, ConfigDict
class ItemBase(BaseModel):
name: str
description: Optional[str] = None
price: int = Field(description="Price in cents")
is_active: bool = True
class ItemCreate(ItemBase):
pass
class ItemUpdate(BaseModel):
name: Optional[str] = None
description: Optional[str] = None
price: Optional[int] = None
is_active: Optional[bool] = None
class ItemInDBBase(ItemBase):
id: int
created_at: datetime
updated_at: Optional[datetime] = None
model_config = ConfigDict(from_attributes=True)
class Item(ItemInDBBase):
"""Response model for API"""
pass
class ItemInDB(ItemInDBBase):
"""Internal model with potential sensitive data"""
pass