Commit 4d34c4ed by Clinton Blackburn

Added support for Swagger API documentation

ECOM-2922
parent 551d6d46
...@@ -28,6 +28,7 @@ INSTALLED_APPS = ( ...@@ -28,6 +28,7 @@ INSTALLED_APPS = (
THIRD_PARTY_APPS = ( THIRD_PARTY_APPS = (
'rest_framework', 'rest_framework',
'rest_framework_swagger',
'social.apps.django_app.default', 'social.apps.django_app.default',
'waffle', 'waffle',
) )
...@@ -117,6 +118,9 @@ TEMPLATES = [ ...@@ -117,6 +118,9 @@ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True, 'APP_DIRS': True,
'DIRS': (
root('templates'),
),
'OPTIONS': { 'OPTIONS': {
'context_processors': ( 'context_processors': (
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
...@@ -222,3 +226,14 @@ LOGGING = { ...@@ -222,3 +226,14 @@ LOGGING = {
}, },
} }
} }
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'VIEW_DESCRIPTION_FUNCTION': 'rest_framework_swagger.views.get_restructuredtext'
}
SWAGGER_SETTINGS = {
'api_version': 'v1',
'doc_expansion': 'list',
}
body {
margin: 0;
}
#header {
background-color: #fcfcfc;
border-bottom: 4px solid #0079bc;
color: #999999;
}
#django-rest-swagger {
background-color: white;
color: #999999;
}
#django-rest-swagger a {
color: inherit;
}
{% extends 'rest_framework_swagger/base.html' %}
{% load staticfiles %}
{% block style %}
{{ block.super }}
<link href='{% static "css/edx-swagger.css" %}' media='screen' rel='stylesheet' type='text/css'/>
{% endblock %}
{% block branding %}
<span id="api-name">edX Course Discovery API</span>
{% endblock %}
{% block api_selector %}
{% endblock %}
...@@ -34,6 +34,7 @@ urlpatterns = [ ...@@ -34,6 +34,7 @@ urlpatterns = [
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^api/', include('course_discovery.apps.api.urls', namespace='api')), url(r'^api/', include('course_discovery.apps.api.urls', namespace='api')),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^api-docs/', include('rest_framework_swagger.urls')),
url(r'^auto_auth/$', core_views.AutoAuth.as_view(), name='auto_auth'), url(r'^auto_auth/$', core_views.AutoAuth.as_view(), name='auto_auth'),
url(r'^health/$', core_views.health, name='health'), url(r'^health/$', core_views.health, name='health'),
url(r'^login/$', login, name='login'), url(r'^login/$', login, name='login'),
...@@ -41,6 +42,7 @@ urlpatterns = [ ...@@ -41,6 +42,7 @@ urlpatterns = [
url('', include('social.apps.django_app.urls', namespace='social')), url('', include('social.apps.django_app.urls', namespace='social')),
] ]
if settings.DEBUG and os.environ.get('ENABLE_DJANGO_TOOLBAR', False): # pragma: no cover if settings.DEBUG and os.environ.get('ENABLE_DJANGO_TOOLBAR', False): # pragma: no cover
import debug_toolbar # pylint: disable=import-error import debug_toolbar # pylint: disable=import-error
urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls))) urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls)))
...@@ -2,5 +2,6 @@ django == 1.8.7 ...@@ -2,5 +2,6 @@ django == 1.8.7
django-extensions == 1.5.9 django-extensions == 1.5.9
django-waffle == 0.11 django-waffle == 0.11
djangorestframework == 3.3.1 djangorestframework == 3.3.1
django-rest-swagger==0.3.4
edx-auth-backends == 0.1.3 edx-auth-backends == 0.1.3
pytz == 2015.7 pytz == 2015.7
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment