forked from microsoft/github-copilot-vibe-coding-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompare_openapi.py
More file actions
34 lines (30 loc) · 1.26 KB
/
Copy pathcompare_openapi.py
File metadata and controls
34 lines (30 loc) · 1.26 KB
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
import requests
import yaml
import sys
from pathlib import Path
def main():
# FastAPI 서버에서 openapi.yaml 다운로드
url = "http://127.0.0.1:8000/openapi.yaml"
response = requests.get(url)
if response.status_code != 200:
print(f"[ERROR] 서버에서 openapi.yaml을 가져오지 못했습니다: {response.status_code}")
sys.exit(1)
server_yaml = yaml.safe_load(response.text)
# 로컬 openapi.yaml 읽기
local_path = Path(__file__).parent.parent / "openapi.yaml"
with open(local_path, "r", encoding="utf-8") as f:
local_yaml = yaml.safe_load(f)
# 비교
if server_yaml == local_yaml:
print("✅ 서버의 openapi.yaml과 로컬 openapi.yaml이 완전히 일치합니다.")
else:
print("❌ 서버의 openapi.yaml과 로컬 openapi.yaml이 다릅니다.")
# 차이점 출력 (간단 비교)
import difflib
server_lines = yaml.dump(server_yaml, sort_keys=True).splitlines()
local_lines = yaml.dump(local_yaml, sort_keys=True).splitlines()
diff = difflib.unified_diff(local_lines, server_lines, fromfile='local openapi.yaml', tofile='server openapi.yaml', lineterm='')
for line in diff:
print(line)
if __name__ == "__main__":
main()