Skip to content

Commit a989de8

Browse files
authored
Merge pull request #277 from Tivix/demo-site-swagger
Add swagger API docs to demo project
2 parents 70d03e3 + 5330e0c commit a989de8

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

demo/demo/settings.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
'rest_auth.registration',
4545
'allauth.socialaccount',
4646
'allauth.socialaccount.providers.facebook',
47+
'rest_framework_swagger',
4748
)
4849

4950
MIDDLEWARE_CLASSES = (
@@ -106,7 +107,7 @@
106107
},
107108
]
108109

109-
REST_SESSION_LOGIN = False
110+
REST_SESSION_LOGIN = True
110111
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
111112
SITE_ID = 1
112113
ACCOUNT_EMAIL_REQUIRED = False
@@ -119,3 +120,8 @@
119120
'rest_framework.authentication.TokenAuthentication',
120121
)
121122
}
123+
124+
SWAGGER_SETTINGS = {
125+
'LOGIN_URL': 'login',
126+
'LOGOUT_URL': 'logout',
127+
}

demo/demo/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from django.contrib import admin
33
from django.views.generic import TemplateView, RedirectView
44

5+
from rest_framework_swagger.views import get_swagger_view
6+
57
urlpatterns = [
68
url(r'^$', TemplateView.as_view(template_name="home.html"), name='home'),
79
url(r'^signup/$', TemplateView.as_view(template_name="signup.html"),
@@ -38,4 +40,5 @@
3840
url(r'^account/', include('allauth.urls')),
3941
url(r'^admin/', include(admin.site.urls)),
4042
url(r'^accounts/profile/$', RedirectView.as_view(url='/', permanent=True), name='profile-redirect'),
43+
url(r'^docs/$', get_swagger_view(title='API Docs'), name='api_docs')
4144
]

demo/requirements.pip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
django>=1.8.0
22
django-rest-auth==0.8.1
3+
djangorestframework==3.5.1
34
django-allauth>=0.24.1
45
six==1.9.0
6+
django-rest-swagger==2.0.7

demo/templates/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<li class="active"><a href="/">Demo</a></li>
6161
<li><a target="_blank" href="http://django-rest-auth.readthedocs.org/en/latest/">Documentation</a></li>
6262
<li><a target="_blank" href="https://github.com/Tivix/django-rest-auth">Source code</a></li>
63+
<li><a target="_blank" href="{% url 'api_docs' %}">API Docs</a></li>
6364
</ul>
6465
</div><!--/.nav-collapse -->
6566
</div>

0 commit comments

Comments
 (0)