main:添加核心文件并初始化项目

新增内容:
- 创建基础项目结构。
- 添加 `.gitignore` 和 `.dockerignore` 文件。
- 编写 `pyproject.toml` 和依赖文件。
- 添加算法模块及示例算法。
- 实现核心功能模块(日志、错误处理、指标)。
- 添加开发和运行所需的相关脚本文件及文档。
This commit is contained in:
2026-02-02 10:46:01 +08:00
commit 31af5e2286
54 changed files with 5726 additions and 0 deletions

35
scripts/export_openapi.py Normal file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/env python3
"""导出 OpenAPI 规范到 JSON 文件"""
import json
import sys
from pathlib import Path
# 添加 src 到路径
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
from functional_scaffold.main import app
def export_openapi():
"""导出 OpenAPI 规范"""
openapi_schema = app.openapi()
# 确保输出目录存在
output_dir = Path(__file__).parent.parent / "docs" / "swagger"
output_dir.mkdir(parents=True, exist_ok=True)
# 写入文件
output_file = output_dir / "openapi.json"
with open(output_file, "w", encoding="utf-8") as f:
json.dump(openapi_schema, f, indent=2, ensure_ascii=False)
print(f"OpenAPI schema exported to: {output_file}")
print(f"Schema version: {openapi_schema.get('openapi')}")
print(f"API title: {openapi_schema.get('info', {}).get('title')}")
print(f"API version: {openapi_schema.get('info', {}).get('version')}")
print(f"Endpoints: {len(openapi_schema.get('paths', {}))}")
if __name__ == "__main__":
export_openapi()