Download backend/scripts/export_openapi.py from YVES28/lerningOs: direct link, hf CLI and curl.
- Browser
- Download file 671 Bytes
-
https://huggingface.co/spaces/YVES28/lerningOs/resolve/main/backend/scripts/export_openapi.py
- Command line
-
hf download hf://spaces/YVES28/lerningOs/backend/scripts/export_openapi.py
-
curl -L -o export_openapi.py https://huggingface.co/spaces/YVES28/lerningOs/resolve/main/backend/scripts/export_openapi.py
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() | |