diff --git a/lms/envs/common.py b/lms/envs/common.py index c267b0dd647701cdcec51264c0f0f1e4771ef82d..7c5cec67f2949dedaef2a2b439676b351abfce4a 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2147,6 +2147,8 @@ INSTALLED_APPS = [ # User API 'rest_framework', + 'drf_yasg', + 'openedx.core.djangoapps.user_api', # Shopping cart diff --git a/lms/urls.py b/lms/urls.py index 2c40254d43be97f11ff732544391d4b69a72972f..dd1190ef196ddc6cf09912e235b46b02c82b84ae 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -8,7 +8,6 @@ from django.conf.urls.static import static from django.contrib.admin import autodiscover as django_autodiscover from django.utils.translation import ugettext_lazy as _ from django.views.generic.base import RedirectView -from rest_framework_swagger.views import get_swagger_view from branding import views as branding_views from config_models.views import ConfigurationModelCurrentAPIView @@ -42,6 +41,7 @@ from openedx.core.djangoapps.programs.models import ProgramsApiConfig from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.core.djangoapps.verified_track_content import views as verified_track_content_views +from openedx.core.openapi import schema_view from openedx.features.enterprise_support.api import enterprise_enabled from ratelimitbackend import admin from static_template_view import views as static_template_view_views @@ -964,7 +964,9 @@ if settings.BRANCH_IO_KEY: if settings.FEATURES.get('ENABLE_API_DOCS'): urlpatterns += [ - url(r'^api-docs/$', get_swagger_view(title='LMS API')), + url(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'), + url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), + url(r'^api-docs/$', schema_view.with_ui('swagger', cache_timeout=0)), ] # edx-drf-extensions csrf app diff --git a/openedx/core/openapi.py b/openedx/core/openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..c7c9a162e4d6f8e1b9b15b88809496b8a235b4aa --- /dev/null +++ b/openedx/core/openapi.py @@ -0,0 +1,20 @@ +""" +Open API support. +""" + +from rest_framework import permissions +from drf_yasg.views import get_schema_view +from drf_yasg import openapi + +schema_view = get_schema_view( + openapi.Info( + title="Snippets API", + default_version='v1', + description="Test description", + terms_of_service="https://www.google.com/policies/terms/", + contact=openapi.Contact(email="contact@snippets.local"), + license=openapi.License(name="BSD License"), + ), + public=True, + permission_classes=(permissions.AllowAny,), +) diff --git a/requirements/edx/base.in b/requirements/edx/base.in index e91f65332d41b095e5c618488a37d25d23797c82..283aea61ce4f56f6f1317cc7068e6effc63e61dc 100644 --- a/requirements/edx/base.in +++ b/requirements/edx/base.in @@ -37,7 +37,7 @@ celery==3.1.25 # Asynchronous task execution library defusedxml Django==1.11.21 # Web application framework django-babel-underscore # underscore template extractor for django-babel (internationalization utilities) -django-config-models>=0.2.2 # Configuration models for Django allowing config management with auditing +django-config-models>=1.0.0 # Configuration models for Django allowing config management with auditing django-cors-headers==2.1.0 # Used to allow to configure CORS headers for cross-domain requests django-countries==4.6.1 # Country data for Django forms and model fields django-crum # Middleware that stores the current request and user in thread local storage @@ -54,7 +54,6 @@ django-pyfs django-ratelimit django-ratelimit-backend==1.1.1 django-require -django-rest-swagger # API documentation django-sekizai django-ses==0.8.4 django-simple-history @@ -64,7 +63,9 @@ django-storages==1.4.1 django-user-tasks django-waffle==0.12.0 django-webpack-loader # Used to wire webpack bundles into the django asset pipeline +djangorestframework==3.7.7 djangorestframework-jwt +drf-yasg # Replacement for django-rest-swagger edx-ace==0.1.10 edx-analytics-data-api-client edx-ccx-keys diff --git a/requirements/edx/github.in b/requirements/edx/github.in index d524efd23f0bd274cd95d9e16eda236dd79b0e3e..0c45f0261471c8470af470cb35824fbcfbb97ae2 100644 --- a/requirements/edx/github.in +++ b/requirements/edx/github.in @@ -66,9 +66,6 @@ git+https://github.com/edx/MongoDBProxy.git@25b99097615bda06bd7cdfe5669ed80dc2a7 # This can go away when we update auth to not use django-rest-framework-oauth git+https://github.com/edx/django-oauth-plus.git@01ec2a161dfc3465f9d35b9211ae790177418316#egg=django-oauth-plus==2.2.9.edx-1 -# Why a DRF fork? See: https://openedx.atlassian.net/browse/PLAT-1581 -git+https://github.com/edx/django-rest-framework.git@1ceda7c086fddffd1c440cc86856441bbf0bd9cb#egg=djangorestframework==3.6.3 - # Why a drf-oauth fork? To add Django 1.11 compatibility to the abandoned repo. # This dependency will be removed by this work: https://openedx.atlassian.net/browse/PLAT-1660 git+https://github.com/edx/django-rest-framework-oauth.git@0a43e8525f1e3048efe4bc70c03de308a277197c#egg=djangorestframework-oauth==1.1.1