diff --git a/botzilla/docs.py b/botzilla/docs.py new file mode 100644 index 0000000..b5ef04f --- /dev/null +++ b/botzilla/docs.py @@ -0,0 +1,36 @@ +from drf_yasg.views import get_schema_view +from drf_yasg import openapi +from drf_yasg.generators import OpenAPISchemaGenerator +from drf_yasg.views import get_schema_view +from rest_framework import permissions + +class SubTagSchemaGenerator(OpenAPISchemaGenerator): + def get_schema(self, request=None, public=False): + schema = super().get_schema(request, public) + # Add x-tagGroups extension for ReDoc + schema['x-tagGroups'] = [ + { + "name": "v1", + "tags": ["token", "conversations"] + } + ] + return schema + +schema_view = get_schema_view( + openapi.Info( + title="Botzilla API", + default_version='v1', + description="Botzilla API documentation", + terms_of_service="https://www.example.com/terms/", + contact=openapi.Contact(email="contact@botzilla.ch"), + license=openapi.License(name="BSD License"), + x_logo={ + "url": "/static/logo.svg", + "backgroundColor": "#FFFFFF", + "altText": "Botzilla logo" + } + ), + public=True, + permission_classes=[permissions.AllowAny], + generator_class=SubTagSchemaGenerator +) \ No newline at end of file diff --git a/botzilla/settings.py b/botzilla/settings.py index 5821fa7..e18158b 100644 --- a/botzilla/settings.py +++ b/botzilla/settings.py @@ -42,7 +42,7 @@ INSTALLED_APPS = [ 'rest_framework_simplejwt', 'rest_framework_simplejwt.token_blacklist', 'api', - + 'app', 'drf_yasg', ] @@ -59,8 +59,8 @@ REST_FRAMEWORK = { } SIMPLE_JWT = { - 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=60 * 12), - 'REFRESH_TOKEN_LIFETIME': timedelta(days=1), + 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=60 * 72), + 'REFRESH_TOKEN_LIFETIME': timedelta(days=31), 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'VERIFYING_KEY': None, @@ -69,7 +69,6 @@ SIMPLE_JWT = { } SWAGGER_SETTINGS = { - 'FAVICON_HREF': '/static/favicon.ico', 'SECURITY_DEFINITIONS': { 'Bearer': { 'type': 'apiKey', diff --git a/botzilla/urls.py b/botzilla/urls.py index c5d357e..fa4aade 100644 --- a/botzilla/urls.py +++ b/botzilla/urls.py @@ -17,29 +17,11 @@ Including another URLconf from django.contrib import admin from django.urls import path, include from rest_framework import permissions -from drf_yasg.views import get_schema_view -from drf_yasg import openapi - -schema_view = get_schema_view( - openapi.Info( - title="Botzilla API", - default_version='v1', - description="Botzilla API documentation", - terms_of_service="https://www.example.com/terms/", - contact=openapi.Contact(email="contact@botzilla.ch"), - license=openapi.License(name="BSD License"), - x_logo={ - "url": "/static/logo.svg", - "backgroundColor": "#FFFFFF", - "altText": "Botzilla logo" - } - ), - public=True, - permission_classes=[permissions.AllowAny], -) +from .docs import schema_view urlpatterns = [ path('admin/', admin.site.urls), path('api/', include('api.urls')), + path('app/', include('app.urls')), path('docs/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), ]