lerningOs / backend /scripts /export_openapi.py
YVES28's picture
Deploy 12D AI Assessment Engine V2.2 (Gradio SDK)
fc51bb8
Raw History Blame Contribute Delete
671 Bytes
import json
import os
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from app.main import app
def export_openapi_spec():
output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../docs/api"))
os.makedirs(output_dir, exist_ok=True)
openapi_data = app.openapi()
file_path = os.path.join(output_dir, "openapi_v1.json")
with open(file_path, "w", encoding="utf-8") as f:
json.dump(openapi_data, f, indent=2, ensure_ascii=False)
print(f"[OpenAPI Spec Exported] Standard OpenAPI 3.1 JSON saved to: {file_path}")
if __name__ == "__main__":
export_openapi_spec()