Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add swagger UI to app #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading