mirror of
https://github.com/daniviga/bite.git
synced 2025-04-20 14:31:20 +02:00
Add swagger ui
This commit is contained in:
parent
b15b88aab4
commit
6970a7c95b
24
bite/bite/templates/swagger.html
Normal file
24
bite/bite/templates/swagger.html
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Swagger</title>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" type="text/css" href="//unpkg.com/swagger-ui-dist@3/swagger-ui.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="swagger-ui"></div>
|
||||||
|
<script src="//unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
|
||||||
|
<script>
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
url: "{% url schema_url %}",
|
||||||
|
dom_id: '#swagger-ui',
|
||||||
|
presets: [
|
||||||
|
SwaggerUIBundle.presets.apis,
|
||||||
|
SwaggerUIBundle.SwaggerUIStandalonePreset
|
||||||
|
],
|
||||||
|
layout: "BaseLayout"
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -34,6 +34,7 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.conf import settings
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
|
|
||||||
from api import urls as api_urls
|
from api import urls as api_urls
|
||||||
@ -45,3 +46,19 @@ urlpatterns = [
|
|||||||
path('api/', include(api_urls)),
|
path('api/', include(api_urls)),
|
||||||
path('telemetry/', include(telemetry_urls)),
|
path('telemetry/', include(telemetry_urls)),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
from django.views.generic import TemplateView
|
||||||
|
from rest_framework.schemas import get_schema_view
|
||||||
|
|
||||||
|
urlpatterns += [
|
||||||
|
path('swagger/', TemplateView.as_view(
|
||||||
|
template_name='swagger.html',
|
||||||
|
extra_context={'schema_url': 'openapi-schema'}
|
||||||
|
), name='swagger'),
|
||||||
|
path('openapi', get_schema_view(
|
||||||
|
title="BITE - A Basic/IoT/Example",
|
||||||
|
description="BITE API for IoT",
|
||||||
|
version="1.0.0"
|
||||||
|
), name='openapi-schema'),
|
||||||
|
]
|
||||||
|
@ -4,5 +4,7 @@ django-health-check
|
|||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
paho-mqtt==1.5.0
|
paho-mqtt==1.5.0
|
||||||
asyncio-mqtt==0.5.0
|
asyncio-mqtt==0.5.0
|
||||||
|
PyYAML
|
||||||
|
uritemplate
|
||||||
pygments
|
pygments
|
||||||
gunicorn
|
gunicorn
|
||||||
|
Loading…
x
Reference in New Issue
Block a user