Add drf-yasg
* Install drf-yasg * Add drf-yasg settings and urls * Pin drf to make drf-yasg work * Adjust config-models version to be compatible * Remove django-rest-swagger (the old way)
This commit is contained in:
@@ -1173,7 +1173,7 @@ INSTALLED_APPS = [
|
||||
'pipeline_mako',
|
||||
|
||||
# API Documentation
|
||||
'rest_framework_swagger',
|
||||
'drf_yasg',
|
||||
|
||||
'openedx.features.course_duration_limits',
|
||||
'openedx.features.content_type_gating',
|
||||
|
||||
@@ -108,6 +108,10 @@ def should_show_debug_toolbar(request):
|
||||
DEBUG_TOOLBAR_MONGO_STACKTRACES = False
|
||||
|
||||
|
||||
########################### API DOCS #################################
|
||||
|
||||
FEATURES['ENABLE_API_DOCS'] = True
|
||||
|
||||
################################ MILESTONES ################################
|
||||
FEATURES['MILESTONES_APP'] = True
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from django.conf.urls import include, url
|
||||
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 rest_framework_swagger.views import get_swagger_view
|
||||
from openedx.core.openapi import schema_view
|
||||
|
||||
import contentstore.views
|
||||
from cms.djangoapps.contentstore.views.organization import OrganizationListView
|
||||
@@ -266,7 +266,9 @@ urlpatterns += [
|
||||
|
||||
if settings.FEATURES.get('ENABLE_API_DOCS'):
|
||||
urlpatterns += [
|
||||
url(r'^api-docs/$', get_swagger_view(title='Studio 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)),
|
||||
]
|
||||
|
||||
from openedx.core.djangoapps.plugins import constants as plugin_constants, plugin_urls
|
||||
|
||||
@@ -2150,6 +2150,7 @@ INSTALLED_APPS = [
|
||||
|
||||
# User API
|
||||
'rest_framework',
|
||||
|
||||
'openedx.core.djangoapps.user_api',
|
||||
|
||||
# Shopping cart
|
||||
@@ -2301,7 +2302,7 @@ INSTALLED_APPS = [
|
||||
'django_filters',
|
||||
|
||||
# API Documentation
|
||||
'rest_framework_swagger',
|
||||
'drf_yasg',
|
||||
|
||||
# edx-drf-extensions
|
||||
'csrf.apps.CsrfAppConfig', # Enables frontend apps to retrieve CSRF tokens.
|
||||
@@ -2331,6 +2332,9 @@ REST_FRAMEWORK = {
|
||||
},
|
||||
}
|
||||
|
||||
SWAGGER_SETTINGS = {
|
||||
'DEFAULT_INFO': 'openedx.core.openapi.openapi_info',
|
||||
}
|
||||
|
||||
######################### MARKETING SITE ###############################
|
||||
EDXMKTG_LOGGED_IN_COOKIE_NAME = 'edxloggedin'
|
||||
|
||||
@@ -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
|
||||
|
||||
22
openedx/core/openapi.py
Normal file
22
openedx/core/openapi.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
Open API support.
|
||||
"""
|
||||
|
||||
from rest_framework import permissions
|
||||
from drf_yasg.views import get_schema_view
|
||||
from drf_yasg import openapi
|
||||
|
||||
openapi_info = openapi.Info(
|
||||
title="Open edX API",
|
||||
default_version="v1",
|
||||
description="APIs for access to Open edX information",
|
||||
#terms_of_service="https://www.google.com/policies/terms/", # TODO: Do we have these?
|
||||
contact=openapi.Contact(email="oscm@edx.org"),
|
||||
#license=openapi.License(name="BSD License"), # TODO: What does this mean?
|
||||
)
|
||||
|
||||
schema_view = get_schema_view(
|
||||
openapi_info,
|
||||
public=True,
|
||||
permission_classes=(permissions.AllowAny,),
|
||||
)
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user