feat: add OpenAPI and Swagger UI endpoints for API documentation
Release / Build & Release (pull_request) Successful in 30s
Release / SonarQube (pull_request) Successful in 25s

This commit is contained in:
2026-07-21 11:12:11 +01:00
parent 1b3404155c
commit 7118f917b8
5 changed files with 2698 additions and 3 deletions
+19
View File
@@ -3370,6 +3370,25 @@ def api_rack_export(rack_id):
as_attachment=True, download_name=f"{rack['name']}_rack.csv".replace(' ', '_'))
# ── API documentation (OpenAPI + Swagger UI) ────────────────────────────────
OPENAPI_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'openapi.json')
SWAGGER_HTML = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static', 'swagger.html')
@app.route('/api/openapi.json')
def api_openapi_spec():
if not os.path.isfile(OPENAPI_PATH):
return jsonify({'error': 'OpenAPI spec not found'}), 404
return send_file(OPENAPI_PATH, mimetype='application/json')
@app.route('/api/docs')
def api_docs():
if not os.path.isfile(SWAGGER_HTML):
return jsonify({'error': 'Swagger UI not found'}), 404
return send_file(SWAGGER_HTML)
# ── SPA static files ──────────────────────────────────────────────────────────
STATIC_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')
DIST = os.path.join(STATIC_ROOT, 'dist')