Automated Action e1b1b89511 Create FastAPI REST API with SQLite
Features:
- Project structure with FastAPI framework
- SQLAlchemy models with SQLite database
- Alembic migrations system
- CRUD operations for items
- API routers with endpoints for items
- Health endpoint for monitoring
- Error handling and validation
- Comprehensive documentation
2025-05-18 05:45:33 +00:00

47 lines
1.1 KiB
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
# Shared properties
class ItemBase(BaseModel):
title: str = Field(
..., min_length=1, max_length=100, description="Title of the item"
)
description: Optional[str] = Field(
None, description="Optional description of the item"
)
is_active: bool = Field(True, description="Is this item active")
# Properties to receive via API on creation
class ItemCreate(ItemBase):
pass
# Properties to receive via API on update
class ItemUpdate(BaseModel):
title: Optional[str] = Field(
None, min_length=1, max_length=100, description="Title of the item"
)
description: Optional[str] = Field(
None, description="Optional description of the item"
)
is_active: Optional[bool] = Field(None, description="Is this item active")
# Properties shared by models stored in DB
class ItemInDBBase(ItemBase):
id: int
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
# Properties to return to client
class Item(ItemInDBBase):
pass