diff --git a/Dockerfile b/Dockerfile index c49ea8e..5f0a446 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,8 @@ LABEL org.opencontainers.image.vendor="JDB-NET" WORKDIR /app COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt -COPY app.py db.py ./ +COPY app.py db.py openapi.json ./ +COPY static/swagger.html ./static/ COPY --from=frontend /app/static/dist ./static/dist ARG VERSION=unknown ENV VERSION=${VERSION} diff --git a/app.py b/app.py index ac7d22d..23b1ab3 100644 --- a/app.py +++ b/app.py @@ -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') diff --git a/frontend/src/views/UsersView.vue b/frontend/src/views/UsersView.vue index 8621def..f13fba9 100644 --- a/frontend/src/views/UsersView.vue +++ b/frontend/src/views/UsersView.vue @@ -135,9 +135,12 @@ async function delRole(id: number) {
-
+

Users

- +
+ API documentation + +