- Add FastAPI application with health check and item CRUD endpoints - Add Pydantic models for request/response validation - Add pytest test suite with 5 passing tests - Add project documentation and run script Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1.3 KiB
1.3 KiB
FastAPI 示例项目实现计划
日期:2026-05-07
目标
搭建一个最小可运行的 FastAPI REST API 示例项目。
任务清单
批次 1:项目基础
| # | 任务 | 文件 | 验证 | 预计时间 |
|---|---|---|---|---|
| 1 | 创建 requirements.txt | requirements.txt | 文件存在 | 1min |
| 2 | 创建项目目录结构 | app/, tests/ | 目录存在 | 1min |
| 3 | 编写数据模型 | app/models.py | 导入成功 | 2min |
批次 2:核心实现(TDD)
| # | 任务 | 文件 | 验证 | 预计时间 |
|---|---|---|---|---|
| 4 | 写失败测试:健康检查 | tests/test_api.py | pytest FAIL | 2min |
| 5 | 实现健康检查端点 | app/main.py | pytest PASS | 2min |
| 6 | 写失败测试:CRUD | tests/test_api.py | pytest FAIL | 3min |
| 7 | 实现 CRUD 端点 | app/routes.py | pytest PASS | 5min |
批次 3:收尾
| # | 任务 | 文件 | 验证 | 预计时间 |
|---|---|---|---|---|
| 8 | 添加启动脚本 | run.sh | 脚本可执行 | 1min |
| 9 | 更新文档 | README.md | 文件存在 | 2min |
验证命令
- 单测:
pytest tests/ -v - 启动:
uvicorn app.main:app --reload
完成标准
- 所有测试通过
- API 可启动并响应
- 代码已提交