28 lines
727 B
Python
28 lines
727 B
Python
"""Export the FastAPI OpenAPI schema as deterministic JSON."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
from app.main import app
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description="Export Vignette API OpenAPI JSON.")
|
|
parser.add_argument("output", type=Path, help="Output JSON path")
|
|
args = parser.parse_args()
|
|
|
|
schema = app.openapi()
|
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
args.output.write_text(
|
|
json.dumps(schema, ensure_ascii=False, indent=2, sort_keys=True) + "\n",
|
|
encoding="utf-8",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|