Skip to content

Commit

Permalink
add swagger UI to app
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrf committed Dec 28, 2023
1 parent 50e34d2 commit a556ce8
Show file tree
Hide file tree
Showing 9 changed files with 4,152 additions and 205 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ install-dependencies:
api-spec:
python patches/generate-api-spec.py
cat patches/api.yaml >> docs/api.yaml
cp docs/api.yaml app/static/api.yaml

api-client: api-spec
rm -rf js/src/api
Expand Down Expand Up @@ -84,6 +85,8 @@ install-js-dependencies: install-mathjax api-client
cp js/node_modules/lightbox2/dist/css/lightbox.css app/static/css/lightbox.css
cp js/node_modules/lightbox2/dist/images/* app/static/images/

cp js/node_modules/swagger-ui/dist/swagger-ui.css app/static/css/swagger-ui.css

js-version:
cd js && npm version --allow-same-version ${RACINE_VERSION}
cd desktop && npm version --allow-same-version ${RACINE_VERSION}
Expand Down
6 changes: 6 additions & 0 deletions app/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def help():
return render_template("help.html", admins=admins, racine_version=RACINE_VERSION)


@main.route("/swagger-ui")
@login_required
def swaggerui():
return render_template("swagger.html", api_token=current_user.get_token())


@main.route("/userlist", methods=["POST"])
@login_required
def userlist():
Expand Down
2 changes: 2 additions & 0 deletions app/static/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mathjax/

css/bootstrap.min.css
css/lightbox.css
css/swagger-ui.css
css/tocbot.css
css/typeahead.css

Expand All @@ -12,4 +13,5 @@ images/loading.gif
images/next.png
images/prev.png

api.yaml
racine.js
1 change: 1 addition & 0 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<li><a href="/print"><i class="hidden-xs glyphicon glyphicon-print" title="Print"></i><span class="visible-xs-block">Print</span></a></li>
<li><a href="/profile/overview"><i class="hidden-xs glyphicon glyphicon-user" title="Profile"></i><span class="hidden-xs">&nbsp;&nbsp;{{ current_user.username }}</span><span class="visible-xs-block">Profile</span></a></li>
<li><a href="{{ url_for('auth.logout') }}"><i class="hidden-xs glyphicon glyphicon-log-out" title="Sign out"></i><span class="visible-xs-block">Sign out</span></a></li>
<li><a href="/swagger-ui"><i class="hidden-xs glyphicon glyphicon-console" title="Swagger UI"></i><span class="visible-xs-block">Swagger UI</span></a></li>
<li><a href="/help"><i class="hidden-xs glyphicon glyphicon-question-sign" title="Help"></i><span class="visible-xs-block">Help</span></a></li>
</ul>
<form class="nav navbar-form navbar-right">
Expand Down
23 changes: 23 additions & 0 deletions app/templates/swagger.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "base.html" %}

{% block styles %}
{{super()}}
<link rel="stylesheet" href="{{url_for('static', filename='css/swagger-ui.css')}}">
{% endblock %}

{% block sidebarnav %}
<div id="sidebar" class="col-sm-3 col-md-2 sidebar">
</div>
{% endblock %}

{% block page_content %}
<div id="swagger-ui"></div>
{% endblock %}

{% block scripts %}
{{ super() }}
<script src="{{ url_for('static', filename='racine.js', version='20230402') }}"></script>
<script>
R.init("{{ api_token }}", "swagger");
</script>
{% endblock %}
Loading

0 comments on commit a556ce8

Please sign in to comment.