This repository has been archived on 2026-07-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core-hub/scripts/export_openapi.py

24 lines
586 B
Python

import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "src"))
from core_hub.app import create_app # noqa: E402
def main() -> int:
target = Path(sys.argv[1]) if len(sys.argv) > 1 else None
payload = json.dumps(create_app().openapi(), indent=2, sort_keys=True) + "\n"
if target:
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text(payload, encoding="utf-8")
else:
sys.stdout.write(payload)
return 0
if __name__ == "__main__":
raise SystemExit(main())