Add swagger API docs to demo project

This commit is contained in:
Maxim Kukhtenkov 2016-10-27 17:42:07 -07:00
parent 37375461df
commit 5330e0cfb1
4 changed files with 13 additions and 1 deletions

View File

@ -44,6 +44,7 @@ INSTALLED_APPS = (
'rest_auth.registration', 'rest_auth.registration',
'allauth.socialaccount', 'allauth.socialaccount',
'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.facebook',
'rest_framework_swagger',
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
@ -106,7 +107,7 @@ TEMPLATES = [
}, },
] ]
REST_SESSION_LOGIN = False REST_SESSION_LOGIN = True
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
SITE_ID = 1 SITE_ID = 1
ACCOUNT_EMAIL_REQUIRED = False ACCOUNT_EMAIL_REQUIRED = False
@ -119,3 +120,8 @@ REST_FRAMEWORK = {
'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.TokenAuthentication',
) )
} }
SWAGGER_SETTINGS = {
'LOGIN_URL': 'login',
'LOGOUT_URL': 'logout',
}

View File

@ -2,6 +2,8 @@ from django.conf.urls import include, url
from django.contrib import admin from django.contrib import admin
from django.views.generic import TemplateView, RedirectView from django.views.generic import TemplateView, RedirectView
from rest_framework_swagger.views import get_swagger_view
urlpatterns = [ urlpatterns = [
url(r'^$', TemplateView.as_view(template_name="home.html"), name='home'), url(r'^$', TemplateView.as_view(template_name="home.html"), name='home'),
url(r'^signup/$', TemplateView.as_view(template_name="signup.html"), url(r'^signup/$', TemplateView.as_view(template_name="signup.html"),
@ -38,4 +40,5 @@ urlpatterns = [
url(r'^account/', include('allauth.urls')), url(r'^account/', include('allauth.urls')),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/profile/$', RedirectView.as_view(url='/', permanent=True), name='profile-redirect'), 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')
] ]

View File

@ -1,4 +1,6 @@
django>=1.8.0 django>=1.8.0
django-rest-auth==0.8.1 django-rest-auth==0.8.1
djangorestframework==3.5.1
django-allauth>=0.24.1 django-allauth>=0.24.1
six==1.9.0 six==1.9.0
django-rest-swagger==2.0.7

View File

@ -60,6 +60,7 @@
<li class="active"><a href="/">Demo</a></li> <li class="active"><a href="/">Demo</a></li>
<li><a target="_blank" href="http://django-rest-auth.readthedocs.org/en/latest/">Documentation</a></li> <li><a target="_blank" href="http://django-rest-auth.readthedocs.org/en/latest/">Documentation</a></li>
<li><a target="_blank" href="https://github.com/Tivix/django-rest-auth">Source code</a></li> <li><a target="_blank" href="https://github.com/Tivix/django-rest-auth">Source code</a></li>
<li><a target="_blank" href="{% url 'api_docs' %}">API Docs</a></li>
</ul> </ul>
</div><!--/.nav-collapse --> </div><!--/.nav-collapse -->
</div> </div>