Added drf_yasg in place of django rest swagger

This commit is contained in:
DJ Gillespie 2022-01-31 19:05:37 -07:00
parent 7172ec9f0d
commit b96c0db896
2 changed files with 28 additions and 4 deletions

View File

@ -48,8 +48,14 @@ INSTALLED_APPS = [
'corsheaders',
'rest_framework_simplejwt.token_blacklist',
'django_filters',
'rest_framework_swagger',
'drf_yasg',
]
SPECTACULAR_SETTINGS = {
'SWAGGER_UI_DIST': 'SIDECAR', # shorthand to use the sidecar instead
'SWAGGER_UI_FAVICON_HREF': 'SIDECAR',
'REDOC_DIST': 'SIDECAR',
# OTHER SETTINGS
}
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

View File

@ -35,9 +35,25 @@ from qrtr_account.views import (AccountViewSet,
TwitterLogin)
from connection.views import ConnectionViewSet, ConnectionTypeViewSet
from rest_framework_swagger.views import get_swagger_view
schema_view = get_swagger_view(title="Qrtr API")
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="Qrtr API",
default_version='v1',
description="",
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="contact@snippets.local"),
license=openapi.License(name="BSD License"),
),
public=True,
permission_classes=[permissions.AllowAny],
)
router = routers.DefaultRouter()
router.register(r'users', UserViewSet)
@ -67,7 +83,9 @@ apipatterns = [
urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/', include(apipatterns), name='api'),
path('api/v1/docs', schema_view),
# path('api/v1/schema/', SpectacularAPIView.as_view(), name='schema'),
path('api/v1/docs', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('api/v1/schema/redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
path('accounts/', include('allauth.urls')),
path('accounts/profile/', ConfirmEmailSuccessView.as_view()),
]