diff --git a/bite/bite/templates/swagger.html b/bite/bite/templates/swagger.html new file mode 100644 index 0000000..b421d7b --- /dev/null +++ b/bite/bite/templates/swagger.html @@ -0,0 +1,24 @@ + + + + Swagger + + + + + +
+ + + + diff --git a/bite/bite/urls.py b/bite/bite/urls.py index 61d2561..ba76354 100644 --- a/bite/bite/urls.py +++ b/bite/bite/urls.py @@ -34,6 +34,7 @@ Including another URLconf """ from django.contrib import admin +from django.conf import settings from django.urls import include, path from api import urls as api_urls @@ -45,3 +46,19 @@ urlpatterns = [ path('api/', include(api_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'), + ] diff --git a/requirements.txt b/requirements.txt index f2c9891..2b4c38d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,7 @@ django-health-check psycopg2-binary paho-mqtt==1.5.0 asyncio-mqtt==0.5.0 +PyYAML +uritemplate pygments gunicorn