32 lines
930 B
Python
32 lines
930 B
Python
"""Export Dify-compatible OpenAPI for File Check tools paste/import."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(ROOT / "backend"))
|
|
|
|
from app.services.file_check_tools.openapi_spec import build_file_check_openapi_spec
|
|
|
|
|
|
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 = build_file_check_openapi_spec(base)
|
|
out_dir = ROOT / "docs" / "openapi"
|
|
out_dir.mkdir(parents=True, exist_ok=True)
|
|
json_path = out_dir / "file_check_tools_openapi.json"
|
|
json_path.write_text(json.dumps(spec, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
print(f"Wrote {json_path}")
|
|
print(f"Import URL: {base}/api/file-check/tools/openapi.json")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|