-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdiff_openapi.py
More file actions
executable file
·34 lines (26 loc) · 882 Bytes
/
diff_openapi.py
File metadata and controls
executable file
·34 lines (26 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from tools.sdk_codegen import build_diff_summary, load_json
def main() -> int:
parser = argparse.ArgumentParser(
description="Diff two OpenAPI specs and emit a markdown summary."
)
parser.add_argument("old", type=Path)
parser.add_argument("new", type=Path)
parser.add_argument("--output", type=Path)
args = parser.parse_args()
summary = build_diff_summary(load_json(args.old), load_json(args.new))
if args.output:
args.output.write_text(summary + "\n")
print(f"Wrote diff summary to {args.output}")
else:
print(summary)
return 0
if __name__ == "__main__":
raise SystemExit(main())