Skip to content

Commit

Permalink
jupyter-servergh-1418: swagger-ui strawman
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed May 2, 2024
1 parent af1342d commit 2d7f64e
Show file tree
Hide file tree
Showing 6 changed files with 4,662 additions and 90 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ docs/gh-pages
jupyter_server/i18n/*/LC_MESSAGES/*.mo
jupyter_server/i18n/*/LC_MESSAGES/nbjs.json
jupyter_server/static/style/*.min.css*
jupyter_server/static/vendor/
node_modules
*.py[co]
__pycache__
Expand Down
13 changes: 13 additions & 0 deletions jupyter_server/services/api/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ def get_content_type(self):
return "text/x-yaml"


class APIDocsHandler(JupyterHandler):
"""A handler for the documentation of the REST API."""

auth_resource = AUTH_RESOURCE

@web.authenticated
@authorized
async def get(self):
"""Get the REST API documentation."""
return self.finish(self.render_template("apidocs.html"))


class APIStatusHandler(APIHandler):
"""An API status handler."""

Expand Down Expand Up @@ -115,6 +127,7 @@ async def get(self):


default_handlers = [
(r"/api/apidocs", APIDocsHandler),
(r"/api/spec.yaml", APISpecHandler),
(r"/api/status", APIStatusHandler),
(r"/api/me", IdentityHandler),
Expand Down
27 changes: 27 additions & 0 deletions jupyter_server/templates/apidocs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "page.html" %}

{% block stylesheet %}
{{ super() }}
<link rel="stylesheet" href="{{ static_url('vendor/swagger-ui/swagger-ui.css') }}" />
<style>
.swagger-ui .info .title small pre {
background-color: transparent;
border: 0;
}
</style>
{% endblock stylesheet %}

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

{% block script %}
{{ super() }}
<script src="{{ static_url('vendor/swagger-ui/swagger-ui-bundle.js') }}"></script>

<script>
;(function(){
SwaggerUIBundle({ url: "./spec.yaml", dom_id: "#swagger-ui" });
}).call(this);
</script>
{% endblock script %}
Loading

0 comments on commit 2d7f64e

Please sign in to comment.