Self hosted FLOSS fitness/workout, nutrition and weight tracker
Start working on documenting the api with drf spectacular
Roland Geider5bd46f9f62cc
diff --git a/requirements.txt b/requirements.txtindex e509af2e9..5f652ba25 100644--- a/requirements.txt+++ b/requirements.txt@@ -23,6 +23,7 @@ django_compressor~=4.3django_extensions~=3.2django-storages~=1.13django-environ==0.10.0+drf-spectacular[sidecar]==0.26.1easy-thumbnails==2.8.5fontawesomefree~=6.3.0icalendar==4.1.0diff --git a/wger/settings_global.py b/wger/settings_global.pyindex 83b21ef04..45c40969c 100644--- a/wger/settings_global.py+++ b/wger/settings_global.py@@ -20,6 +20,9 @@ import osimport refrom datetime import timedelta+# wger+from wger import get_version+"""This file contains the global settings that don't usually need to be changed.@@ -87,6 +90,8 @@ INSTALLED_APPS = ('rest_framework.authtoken','django_filters','rest_framework_simplejwt',+ 'drf_spectacular',+ 'drf_spectacular_sidecar',# Breadcrumbs'django_bootstrap_breadcrumbs',@@ -446,7 +451,21 @@ REST_FRAMEWORK = {'DEFAULT_THROTTLE_CLASSES': ['rest_framework.throttling.ScopedRateThrottle'],'DEFAULT_THROTTLE_RATES': {'login': '3/min'- }+ },+ 'DEFAULT_SCHEMA_CLASS':+ 'drf_spectacular.openapi.AutoSchema',+}++# Api docs+SPECTACULAR_SETTINGS = {+ 'TITLE': 'wger workout manager',+ 'DESCRIPTION': 'FLOSS self hosted workout and fitness tracker',+ 'VERSION': get_version(),+ 'SERVE_INCLUDE_SCHEMA': False,+ 'SCHEMA_PATH_PREFIX': '/api/v[0-9]',+ 'SWAGGER_UI_DIST': 'SIDECAR',+ 'SWAGGER_UI_FAVICON_HREF': 'SIDECAR',+ 'REDOC_DIST': 'SIDECAR',}#diff --git a/wger/urls.py b/wger/urls.pyindex 13572f6a9..aacdda213 100644--- a/wger/urls.py+++ b/wger/urls.py@@ -29,6 +29,11 @@ from django.urls import path# Third Partyfrom django_email_verification import urls as email_urls+from drf_spectacular.views import (+ SpectacularAPIView,+ SpectacularRedocView,+ SpectacularSwaggerView,+)from rest_framework import routersfrom rest_framework_simplejwt.views import (TokenObtainPairView,@@ -48,7 +53,6 @@ from wger.nutrition.sitemap import NutritionSitemapfrom wger.utils.generic_views import TextTemplateViewfrom wger.weight.api import views as weight_api_views-# admin.autodiscover()#@@ -275,6 +279,23 @@ urlpatterns += [name='min_app_version'),path('email/', include(email_urls)),++ # Api documentation+ path(+ 'api/schema/',+ SpectacularAPIView.as_view(),+ name='schema',+ ),+ path(+ 'api/schema/swagger-ui/',+ SpectacularSwaggerView.as_view(url_name='schema'),+ name='swagger-ui'+ ),+ path(+ 'api/schema/redoc/',+ SpectacularRedocView.as_view(url_name='schema'),+ name='redoc'+ ),]#