Commit 4ed4b74d by Douglas Hall

Use django-rest-swagger for API doc generation.

parent 701c1f0c
...@@ -281,6 +281,7 @@ DJANGO_APPS = [ ...@@ -281,6 +281,7 @@ DJANGO_APPS = [
'crispy_forms', 'crispy_forms',
'solo', 'solo',
'social_django', 'social_django',
'rest_framework_swagger',
] ]
# Apps specific to this project go here. # Apps specific to this project go here.
......
body {
background-color: white;
}
#django-rest-swagger {
background-color: white;
color: #999999;
a {
color: inherit;
}
}
.swagger-ui-wrap {
.container {
// Undo Bootstrap's container width
width: initial;
}
}
{% extends 'rest_framework_swagger/base.html' %}
{% load compress %}
{% load core_extras %}
{% load static %}
{% block title %}edX E-Commerce API {{ swagger_settings.api_version }}{% endblock %}
{% block style %}
{{ block.super }}
{% compress css %}
{% if main_css %}
<link rel="stylesheet" href="{{ main_css }}" type="text/x-scss">
{% else %}
<link rel="stylesheet" href="{% static 'css/base/main.css' %}" type="text/x-scss">
{% endif %}
{% if swagger_css %}
<link rel="stylesheet" href="{{ swagger_css }}" type="text/x-scss">
{% else %}
<link rel="stylesheet" href="{% static 'css/base/edx-swagger.css' %}" type="text/x-scss">
{% endif %}
{% endcompress %}
{% endblock %}
{% block branding %}
{% endblock %}
{% block header %}
{% include 'edx/partials/_staff_navbar.html' %}
{% endblock %}
{% block body %}
{# NOTE: Loading RequireJS, config.js, and common.js conflicts with Swagger's JS dependencies. Load our updated version of jQuery first, so that bootstrap.js loads properly. #}
{% compress js %}
<script src="{% static 'bower_components/jquery/dist/jquery.js' %}"></script>
<script src="{% static 'bower_components/bootstrap-sass/assets/javascripts/bootstrap.js' %}"></script>
{% endcompress %}
{{ block.super }}
{% endblock %}
...@@ -22,7 +22,7 @@ class TestUrls(TestCase): ...@@ -22,7 +22,7 @@ class TestUrls(TestCase):
""" """
Verify that the API docs render. Verify that the API docs render.
""" """
path = reverse('api-docs:docs-index') path = reverse('api_docs')
response = self.client.get(path) response = self.client.get(path)
assert response.status_code == 200 assert response.status_code == 200
...@@ -11,18 +11,14 @@ def offline_context(): ...@@ -11,18 +11,14 @@ def offline_context():
through all applied themes and returns a separate context for each theme. through all applied themes and returns a separate context for each theme.
""" """
main_css_path = "css/base/main.css" main_css_path = "css/base/main.css"
swagger_css_path = "css/base/edx-swagger.css"
for theme in get_themes(): for theme in get_themes():
main_css = ThemeStorage(prefix=theme.theme_dir_name).url(main_css_path) main_css = ThemeStorage(prefix=theme.theme_dir_name).url(main_css_path)
swagger_css = ThemeStorage(prefix=theme.theme_dir_name).url(swagger_css_path)
yield { yield {
'main_css': main_css, 'main_css': main_css,
'swagger_css': swagger_css,
} }
yield { yield {
'main_css': ThemeStorage().url(main_css_path), 'main_css': ThemeStorage().url(main_css_path),
'swagger_css': ThemeStorage().url(swagger_css_path),
} }
...@@ -10,7 +10,7 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -10,7 +10,7 @@ from django.utils.translation import ugettext_lazy as _
from django.views.defaults import page_not_found, server_error from django.views.defaults import page_not_found, server_error
from django.views.generic import TemplateView from django.views.generic import TemplateView
from django.views.i18n import JavaScriptCatalog from django.views.i18n import JavaScriptCatalog
from rest_framework.documentation import include_docs_urls from rest_framework_swagger.views import get_swagger_view
from ecommerce.core import views as core_views from ecommerce.core import views as core_views
from ecommerce.core.url_utils import get_lms_dashboard_url from ecommerce.core.url_utils import get_lms_dashboard_url
...@@ -54,7 +54,7 @@ urlpatterns = AUTH_URLS + WELL_KNOWN_URLS + [ ...@@ -54,7 +54,7 @@ urlpatterns = AUTH_URLS + WELL_KNOWN_URLS + [
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.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'^api-auth/', include(AUTH_URLS, namespace='rest_framework')), url(r'^api-auth/', include(AUTH_URLS, namespace='rest_framework')),
url(r'^api-docs/', include_docs_urls(title='Ecommerce API')), url(r'^api-docs/', get_swagger_view(title='Ecommerce API'), name='api_docs'),
url(r'^courses/', include('ecommerce.courses.urls', namespace='courses')), url(r'^courses/', include('ecommerce.courses.urls', namespace='courses')),
url(r'^credit/', include('ecommerce.credit.urls', namespace='credit')), url(r'^credit/', include('ecommerce.credit.urls', namespace='credit')),
url(r'^coupons/', include('ecommerce.coupons.urls', namespace='coupons')), url(r'^coupons/', include('ecommerce.coupons.urls', namespace='coupons')),
......
...@@ -13,6 +13,7 @@ django_extensions==1.9.9 ...@@ -13,6 +13,7 @@ django_extensions==1.9.9
django-filter==1.0.4 django-filter==1.0.4
django-libsass==0.5 django-libsass==0.5
django-oscar==1.5.1 django-oscar==1.5.1
django-rest-swagger==2.2.0
django-solo==1.1.2 django-solo==1.1.2
django-threadlocals==0.8 django-threadlocals==0.8
django-waffle==0.12.0 django-waffle==0.12.0
......
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