2019-12-23 20:43:20 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# gen-doc.py - Generate a Swagger JSON document for the API
|
|
|
|
# Part of the Parallel Virtual Cluster (PVC) system
|
|
|
|
|
|
|
|
from flask_swagger import swagger
|
2019-12-23 20:51:31 -05:00
|
|
|
import os
|
2019-12-23 20:43:20 -05:00
|
|
|
import sys
|
|
|
|
import json
|
|
|
|
|
2020-02-08 19:16:19 -05:00
|
|
|
os.environ['PVC_CONFIG_FILE'] = "./api-daemon/pvcapid.sample.yaml"
|
2019-12-23 20:51:31 -05:00
|
|
|
|
2020-02-08 18:48:59 -05:00
|
|
|
sys.path.append('api-daemon')
|
2019-12-23 20:43:20 -05:00
|
|
|
|
2020-02-08 20:36:53 -05:00
|
|
|
import pvcapid.flaskapi as pvc_api
|
2019-12-23 20:43:20 -05:00
|
|
|
|
2023-09-21 02:32:53 -04:00
|
|
|
swagger_file = "swagger.json"
|
2019-12-23 20:43:20 -05:00
|
|
|
swagger_data = swagger(pvc_api.app)
|
|
|
|
swagger_data['info']['version'] = "1.0"
|
|
|
|
swagger_data['info']['title'] = "PVC Client and Provisioner API"
|
2020-01-06 23:50:12 -05:00
|
|
|
swagger_data['host'] = "pvc.local:7370"
|
2019-12-23 20:43:20 -05:00
|
|
|
|
|
|
|
with open(swagger_file, 'w') as fd:
|
|
|
|
fd.write(json.dumps(swagger_data, sort_keys=True, indent=4))
|
2023-09-21 02:32:53 -04:00
|
|
|
|
|
|
|
print(f"Swagger file output to {swagger_file}; add it to the PVC documentation repo.")
|