generated from coulomb/repo-seed
Start Core Hub FastAPI replacement foundation
This commit is contained in:
23
scripts/export_openapi.py
Normal file
23
scripts/export_openapi.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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())
|
||||
Reference in New Issue
Block a user