File size: 671 Bytes
fc51bb8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()