From e588462d11c3b61c1ac18ab11b09307a665b41f2 Mon Sep 17 00:00:00 2001 From: hashlash Date: Mon, 25 Jan 2021 07:19:04 +0700 Subject: [PATCH] Use drf-yasg for demo project --- demo/demo/settings.py | 2 +- demo/demo/urls.py | 12 ++++++++++-- demo/requirements.pip | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/demo/demo/settings.py b/demo/demo/settings.py index 03de0a13..e207bc58 100644 --- a/demo/demo/settings.py +++ b/demo/demo/settings.py @@ -42,7 +42,7 @@ 'dj_rest_auth.registration', 'allauth.socialaccount', 'allauth.socialaccount.providers.facebook', - 'rest_framework_swagger', + 'drf_yasg', 'corsheaders' ) diff --git a/demo/demo/urls.py b/demo/demo/urls.py index 4f63ba13..eb1b41f0 100644 --- a/demo/demo/urls.py +++ b/demo/demo/urls.py @@ -1,7 +1,15 @@ from django.conf.urls import include, url from django.contrib import admin from django.views.generic import RedirectView, TemplateView -from rest_framework_swagger.views import get_swagger_view +from drf_yasg.views import get_schema_view +from drf_yasg import openapi + +schema_view = get_schema_view( + openapi.Info( + title='API Docs', + default_version='v1', + ) +) urlpatterns = [ url(r'^$', TemplateView.as_view(template_name="home.html"), name='home'), @@ -39,5 +47,5 @@ url(r'^account/', include('allauth.urls')), url(r'^admin/', admin.site.urls), url(r'^accounts/profile/$', RedirectView.as_view(url='/', permanent=True), name='profile-redirect'), - url(r'^docs/$', get_swagger_view(title='API Docs'), name='api_docs') + url(r'^docs/$', schema_view.with_ui('swagger', cache_timeout=0), name='api_docs') ] diff --git a/demo/requirements.pip b/demo/requirements.pip index 4a0061af..c2a37e71 100644 --- a/demo/requirements.pip +++ b/demo/requirements.pip @@ -3,6 +3,6 @@ dj-rest-auth @ git+https://github.com/jazzband/dj-rest-auth.git@master djangorestframework>=3.11.0 djangorestframework-simplejwt==4.4.0 django-allauth>=0.24.1 -django-rest-swagger==2.0.7 +drf-yasg==1.20.0 django-cors-headers==3.2.1 coreapi==2.3.3