Skip to content

Commit eac3eba

Browse files
committed
Feature: added Swagger UI application to api documentation
1 parent eb5c1e2 commit eac3eba

19 files changed

+110
-0
lines changed

src/docs/py/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .docs import doc_app

src/docs/py/docs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os
2+
from pathlib import Path
3+
from flask import Blueprint, render_template
4+
5+
doc_app = Blueprint("docs", __name__,
6+
template_folder=os.path.join(Path(__file__).parent.parent, "swagger-ui", "templates"),
7+
static_folder= os.path.join(Path(__file__).parent.parent, "swagger-ui", "static"))
8+
9+
10+
@doc_app.route("/docs")
11+
def get_docs():
12+
return render_template("index.html")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
html {
2+
box-sizing: border-box;
3+
overflow: -moz-scrollbars-vertical;
4+
overflow-y: scroll;
5+
}
6+
7+
*,
8+
*:before,
9+
*:after {
10+
box-sizing: inherit;
11+
}
12+
13+
body {
14+
margin: 0;
15+
background: #fafafa;
16+
}

src/docs/swagger-ui/static/css/swagger-ui.css

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/css/swagger-ui.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
window.onload = function() {
2+
//<editor-fold desc="Changeable Configuration Block">
3+
4+
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
5+
window.ui = SwaggerUIBundle({
6+
url: "{{ url_for('docs.static', filename='openapi.yaml') }}",
7+
dom_id: '#swagger-ui',
8+
deepLinking: true,
9+
presets: [
10+
SwaggerUIBundle.presets.apis,
11+
SwaggerUIStandalonePreset
12+
],
13+
plugins: [
14+
SwaggerUIBundle.plugins.DownloadUrl
15+
],
16+
layout: "StandaloneLayout"
17+
});
18+
19+
//</editor-fold>
20+
};

src/docs/swagger-ui/static/js/swagger-ui-bundle.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/js/swagger-ui-bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/js/swagger-ui-es-bundle-core.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/js/swagger-ui-es-bundle-core.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/js/swagger-ui-es-bundle.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/js/swagger-ui-es-bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/js/swagger-ui-standalone-preset.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/js/swagger-ui-standalone-preset.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/js/swagger-ui.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/swagger-ui/static/js/swagger-ui.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
665 Bytes
Loading
628 Bytes
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!-- HTML for static distribution bundle build -->
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Swagger UI</title>
7+
<link rel="stylesheet" type="text/css" href="{{ url_for('docs.static', filename='css/swagger-ui.css') }}" />
8+
<link rel="stylesheet" type="text/css" href="{{ url_for('docs.static', filename='css/index.css') }}" />
9+
<link rel="icon" type="image/png" href="{{ url_for('docs.static', filename='css/favicon-32x32.png') }}" sizes="32x32" />
10+
<link rel="icon" type="image/png" href="{{ url_for('docs.static', filename='css/favicon-16x16.png') }}" sizes="16x16" />
11+
</head>
12+
13+
<body>
14+
<div id="swagger-ui"></div>
15+
<script src="{{ url_for('docs.static', filename='js/swagger-ui-bundle.js') }}" charset="UTF-8"> </script>
16+
<script src="{{ url_for('docs.static', filename='js/swagger-ui-standalone-preset.js') }}" charset="UTF-8"> </script>
17+
<script>
18+
window.onload = function() {
19+
//<editor-fold desc="Changeable Configuration Block">
20+
21+
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
22+
window.ui = SwaggerUIBundle({
23+
url: "{{ url_for('docs.static', filename='openapi.yaml') }}",
24+
dom_id: '#swagger-ui',
25+
deepLinking: true,
26+
presets: [
27+
SwaggerUIBundle.presets.apis,
28+
SwaggerUIStandalonePreset
29+
],
30+
plugins: [
31+
SwaggerUIBundle.plugins.DownloadUrl
32+
],
33+
layout: "StandaloneLayout"
34+
});
35+
36+
//</editor-fold>
37+
};
38+
</script>
39+
<!-- <script src="{{ url_for('docs.static', filename='js/swagger-initializer.js')}}" charset="UTF-8"> </script> -->
40+
</body>
41+
</html>

0 commit comments

Comments
 (0)