feat(agent): 立账凭证检核
(cherry picked from commit f9e2fb5efc1ec7bf4f6e52e08dd3591b4e77edd9)
This commit is contained in:
1 parent
9bcbf9d211
commit
f615e56bb9
70 files changed
+4968
-108
No files matched your search
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
backend/scripts/export_voucher_check_openapi.py
|
||||
|
||||
用途:导出立账凭证检核 Tool OpenAPI 到 docs/openapi,供 Dify 粘贴/对比。
|
||||
依赖:voucher_check.openapi_spec。
|
||||
逻辑:仓库静态 JSON 使用占位地址;各环境请用 URL 导入 GET .../openapi.json。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
# 不经 app 包导入,避免导出脚本依赖本机 Flask venv
|
||||
_SPEC_PATH = ROOT / "backend" / "app" / "services" / "voucher_check" / "openapi_base.json"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
base = (
|
||||
os.getenv("HXOPS_TOOLS_API_BASE")
|
||||
or os.getenv("PUBLIC_BASE_URL")
|
||||
or "http://127.0.0.1:5052"
|
||||
).rstrip("/")
|
||||
spec = json.loads(_SPEC_PATH.read_text(encoding="utf-8"))
|
||||
if isinstance(spec.get("servers"), list) and spec["servers"]:
|
||||
spec["servers"][0]["url"] = base
|
||||
spec["servers"][0]["description"] = "HXOPS_TOOLS_API_BASE"
|
||||
out_dir = ROOT / "docs" / "openapi"
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
json_path = out_dir / "accounting_voucher_check_tools_openapi.json"
|
||||
json_path.write_text(json.dumps(spec, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
||||
print(f"Wrote {json_path}")
|
||||
print(f"Import URL: {base}/api/accounting-voucher-check/tools/openapi.json")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user