Automated Action a030964e07 Implement REST API with FastAPI and SQLite
- Set up project structure and dependencies
- Implement database models with SQLAlchemy
- Set up Alembic migrations
- Create FastAPI application with CORS support
- Implement API endpoints (CRUD operations)
- Add health check endpoint
- Update README with setup and usage instructions
2025-06-03 12:23:52 +00:00

29 lines
849 B
Python

from typing import Optional
from datetime import datetime
from pydantic import BaseModel, Field, ConfigDict
# Base schema for item shared properties
class ItemBase(BaseModel):
name: str = Field(..., min_length=1, max_length=255)
description: Optional[str] = None
price: int = Field(..., ge=0) # Price in cents, must be >= 0
is_active: bool = True
# Schema for creating an item
class ItemCreate(ItemBase):
pass
# Schema for updating an item
class ItemUpdate(BaseModel):
name: Optional[str] = Field(None, min_length=1, max_length=255)
description: Optional[str] = None
price: Optional[int] = Field(None, ge=0)
is_active: Optional[bool] = None
# Schema for item response
class Item(ItemBase):
id: int
created_at: datetime
updated_at: datetime
model_config = ConfigDict(from_attributes=True)