diff --git a/ecommerce/settings/base.py b/ecommerce/settings/base.py index 13d0fa005f4..b1c51ef85b4 100644 --- a/ecommerce/settings/base.py +++ b/ecommerce/settings/base.py @@ -301,7 +301,7 @@ 'crispy_forms', 'solo', 'social_django', - 'rest_framework_swagger', + 'drf_yasg', 'rest_framework_datatables', 'django_sites_extensions', # edx-drf-extensions diff --git a/ecommerce/urls.py b/ecommerce/urls.py index 32b37e78b61..94fa85c0979 100644 --- a/ecommerce/urls.py +++ b/ecommerce/urls.py @@ -12,7 +12,9 @@ from django.views.defaults import page_not_found, server_error from django.views.generic import TemplateView from django.views.i18n import JavaScriptCatalog -from rest_framework_swagger.views import get_swagger_view +from drf_yasg import openapi +from drf_yasg.views import get_schema_view +from rest_framework import permissions from ecommerce.core import views as core_views from ecommerce.core.url_utils import get_lms_dashboard_url @@ -52,11 +54,21 @@ def handler403(_, exception): # pylint: disable=unused-argument ApplePayMerchantDomainAssociationView.as_view(), name='apple_pay_domain_association'), ] +schema_view = get_schema_view( + openapi.Info( + title="Ecommerce API", + default_version='v2', + description="Ecommerce docs", + ), + public=False, + permission_classes=[permissions.AllowAny], +) + urlpatterns = AUTH_URLS + WELL_KNOWN_URLS + [ url(r'^admin/', admin.site.urls), url(r'^auto_auth/$', core_views.AutoAuth.as_view(), name='auto_auth'), url(r'^api-auth/', include((AUTH_URLS, 'rest_framework'))), - url(r'^api-docs/', get_swagger_view(title='Ecommerce API'), name='api_docs'), + url(r'^api-docs/$', schema_view.with_ui('swagger', cache_timeout=0), name='api_docs'), url(r'^bff/', include(('ecommerce.bff.urls', 'bff'))), url(r'^courses/', include(('ecommerce.courses.urls', 'courses'))), url(r'^credit/', include(('ecommerce.credit.urls', 'credit'))), diff --git a/requirements/base.in b/requirements/base.in index b2a0b803da3..8d7d22f2b8f 100755 --- a/requirements/base.in +++ b/requirements/base.in @@ -14,7 +14,6 @@ django_extensions django-filter django-libsass django-oscar -django-rest-swagger django-simple-history django-solo django-threadlocals @@ -23,6 +22,7 @@ djangorestframework djangorestframework-csv djangorestframework-datatables drf-extensions +drf-yasg edx-auth-backends edx-django-release-util edx-django-utils diff --git a/requirements/base.txt b/requirements/base.txt index 50dd59c6ee4..0e3a1abd176 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -59,11 +59,12 @@ configparser==5.0.2 coreapi==2.3.3 # via # -r requirements/base.in - # django-rest-swagger - # openapi-codec + # drf-yasg coreschema==0.0.4 - # via coreapi -coverage==6.0.1 + # via + # coreapi + # drf-yasg +coverage==6.2 # via cybersource-rest-client-python crypto==1.4.1 # via cybersource-rest-client-python @@ -107,6 +108,7 @@ django==2.2.24 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg # edx-auth-backends # edx-django-release-util # edx-django-sites-extensions @@ -150,8 +152,6 @@ django-oscar==2.0.4 # -r requirements/base.in django-phonenumber-field==2.0.1 # via django-oscar -django-rest-swagger==2.2.0 - # via -r requirements/base.in django-simple-history==3.0.0 # via -r requirements/base.in django-solo==1.2.0 @@ -173,11 +173,11 @@ djangorestframework==3.12.4 # via # -r requirements/base.in # django-config-models - # django-rest-swagger # djangorestframework-csv # djangorestframework-datatables # drf-extensions # drf-jwt + # drf-yasg # edx-drf-extensions # rest-condition djangorestframework-csv==2.1.1 @@ -188,6 +188,8 @@ drf-extensions==0.7.1 # via -r requirements/base.in drf-jwt==1.19.1 # via edx-drf-extensions +drf-yasg==1.20.0 + # via -r requirements/base.in edx-auth-backends==3.4.0 # via # -c requirements/pins.txt @@ -243,6 +245,8 @@ idna==2.7 # -c requirements/pins.txt # cybersource-rest-client-python # requests +inflection==0.5.1 + # via drf-yasg ipaddress==1.0.23 # via cybersource-rest-client-python isodate==0.6.0 @@ -303,10 +307,10 @@ oauthlib==3.1.1 # via # requests-oauthlib # social-auth-core -openapi-codec==1.3.2 - # via django-rest-swagger -packaging==21.0 - # via bleach +packaging==21.3 + # via + # bleach + # drf-yasg paramiko==2.7.2 # via cybersource-rest-client-python path.py==7.2 @@ -445,7 +449,11 @@ rjsmin==1.1.0 # via django-compressor rsa==4.7.2 # via cybersource-rest-client-python -rules==3.0 +ruamel.yaml==0.17.21 + # via drf-yasg +ruamel.yaml.clib==0.2.6 + # via ruamel.yaml +rules==3.1 # via -r requirements/base.in s3transfer==0.5.0 # via boto3 @@ -455,8 +463,6 @@ shellescape==3.8.1 # via # crypto # cybersource-rest-client-python -simplejson==3.17.5 - # via django-rest-swagger six==1.16.0 # via # analytics-python @@ -521,9 +527,11 @@ unicodecsv==0.14.1 # via # -r requirements/base.in # djangorestframework-csv -uritemplate==3.0.1 - # via coreapi -urllib3==1.26.7 +uritemplate==4.1.1 + # via + # coreapi + # drf-yasg +urllib3==1.26.8 # via # -c requirements/pins.txt # botocore diff --git a/requirements/dev.txt b/requirements/dev.txt index da5fb6bcefe..613a8cd14ed 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -101,13 +101,13 @@ configparser==5.0.2 coreapi==2.3.3 # via # -r requirements/test.txt - # django-rest-swagger - # openapi-codec + # drf-yasg coreschema==0.0.4 # via # -r requirements/test.txt # coreapi -coverage[toml]==6.0.1 + # drf-yasg +coverage[toml]==6.2 # via # -r requirements/test.txt # cybersource-rest-client-python @@ -166,6 +166,7 @@ django==2.2.24 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg # edx-auth-backends # edx-django-release-util # edx-django-sites-extensions @@ -223,8 +224,6 @@ django-phonenumber-field==2.0.1 # via # -r requirements/test.txt # django-oscar -django-rest-swagger==2.2.0 - # via -r requirements/test.txt django-simple-history==3.0.0 # via -r requirements/test.txt django-solo==1.2.0 @@ -254,11 +253,11 @@ djangorestframework==3.12.4 # via # -r requirements/test.txt # django-config-models - # django-rest-swagger # djangorestframework-csv # djangorestframework-datatables # drf-extensions # drf-jwt + # drf-yasg # edx-drf-extensions # rest-condition djangorestframework-csv==2.1.1 @@ -275,6 +274,8 @@ drf-jwt==1.19.1 # via # -r requirements/test.txt # edx-drf-extensions +drf-yasg==1.20.0 + # via -r requirements/test.txt edx-auth-backends==3.4.0 # via -r requirements/test.txt edx-django-release-util==1.1.0 @@ -364,7 +365,11 @@ importlib-metadata==4.8.1 # via # -r requirements/test.txt # pytest-randomly -inflect==5.3.0 +inflection==0.5.1 + # via + # -r requirements/test.txt + # drf-yasg +iniconfig==1.1.1 # via # -r requirements/test.txt # jinja2-pluralize @@ -484,15 +489,12 @@ oauthlib==3.1.1 # -r requirements/test.txt # requests-oauthlib # social-auth-core -openapi-codec==1.3.2 - # via - # -r requirements/test.txt - # django-rest-swagger -packaging==21.0 +packaging==21.3 # via # -r requirements/docs.txt # -r requirements/test.txt # bleach + # drf-yasg # pytest # sphinx # tox @@ -778,7 +780,15 @@ rsa==4.7.2 # via # -r requirements/test.txt # cybersource-rest-client-python -rules==3.0 +ruamel.yaml==0.17.21 + # via + # -r requirements/test.txt + # drf-yasg +ruamel.yaml.clib==0.2.6 + # via + # -r requirements/test.txt + # ruamel.yaml +rules==3.1 # via -r requirements/test.txt s3transfer==0.5.0 # via @@ -798,10 +808,6 @@ shellescape==3.8.1 # -r requirements/test.txt # crypto # cybersource-rest-client-python -simplejson==3.17.5 - # via - # -r requirements/test.txt - # django-rest-swagger six==1.16.0 # via # -r requirements/docs.txt @@ -956,7 +962,8 @@ uritemplate==3.0.1 # via # -r requirements/test.txt # coreapi -urllib3==1.26.7 + # drf-yasg +urllib3==1.26.8 # via # -r requirements/docs.txt # -r requirements/test.txt diff --git a/requirements/production.txt b/requirements/production.txt index 7abeb77a25a..e0d7a895618 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -61,11 +61,12 @@ configparser==5.0.2 coreapi==2.3.3 # via # -r requirements/base.in - # django-rest-swagger - # openapi-codec + # drf-yasg coreschema==0.0.4 - # via coreapi -coverage==6.0.1 + # via + # coreapi + # drf-yasg +coverage==6.2 # via cybersource-rest-client-python crypto==1.4.1 # via cybersource-rest-client-python @@ -110,6 +111,7 @@ django==2.2.24 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg # edx-auth-backends # edx-django-release-util # edx-django-sites-extensions @@ -153,9 +155,7 @@ django-oscar==2.0.4 # -r requirements/base.in django-phonenumber-field==2.0.1 # via django-oscar -django-rest-swagger==2.2.0 - # via -r requirements/base.in -django-ses==2.3.0 +django-ses==2.3.1 # via -r requirements/production.in django-simple-history==3.0.0 # via -r requirements/base.in @@ -178,11 +178,11 @@ djangorestframework==3.12.4 # via # -r requirements/base.in # django-config-models - # django-rest-swagger # djangorestframework-csv # djangorestframework-datatables # drf-extensions # drf-jwt + # drf-yasg # edx-drf-extensions # rest-condition djangorestframework-csv==2.1.1 @@ -193,6 +193,8 @@ drf-extensions==0.7.1 # via -r requirements/base.in drf-jwt==1.19.1 # via edx-drf-extensions +drf-yasg==1.20.0 + # via -r requirements/base.in edx-auth-backends==3.4.0 # via # -c requirements/pins.txt @@ -252,6 +254,8 @@ idna==2.7 # -c requirements/pins.txt # cybersource-rest-client-python # requests +inflection==0.5.1 + # via drf-yasg ipaddress==1.0.23 # via cybersource-rest-client-python isodate==0.6.0 @@ -315,11 +319,12 @@ oauthlib==3.1.1 # via # requests-oauthlib # social-auth-core -openapi-codec==1.3.2 - # via django-rest-swagger -packaging==21.0 - # via bleach -paramiko==2.7.2 +packaging==21.3 + # via + # bleach + # drf-yasg + # redis +paramiko==2.9.2 # via cybersource-rest-client-python path.py==7.2 # via -r requirements/base.in @@ -463,7 +468,11 @@ rjsmin==1.1.0 # via django-compressor rsa==4.7.2 # via cybersource-rest-client-python -rules==3.0 +ruamel.yaml==0.17.21 + # via drf-yasg +ruamel.yaml.clib==0.2.6 + # via ruamel.yaml +rules==3.1 # via -r requirements/base.in s3transfer==0.5.0 # via boto3 @@ -473,8 +482,6 @@ shellescape==3.8.1 # via # crypto # cybersource-rest-client-python -simplejson==3.17.5 - # via django-rest-swagger six==1.16.0 # via # analytics-python @@ -540,9 +547,11 @@ unicodecsv==0.14.1 # via # -r requirements/base.in # djangorestframework-csv -uritemplate==3.0.1 - # via coreapi -urllib3==1.26.7 +uritemplate==4.1.1 + # via + # coreapi + # drf-yasg +urllib3==1.26.8 # via # -c requirements/pins.txt # botocore diff --git a/requirements/test.txt b/requirements/test.txt index b4a1ffec24a..db47d48781d 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -94,13 +94,13 @@ configparser==5.0.2 coreapi==2.3.3 # via # -r requirements/base.txt - # django-rest-swagger - # openapi-codec + # drf-yasg coreschema==0.0.4 # via # -r requirements/base.txt # coreapi -coverage[toml]==6.0.1 + # drf-yasg +coverage[toml]==6.2 # via # -r requirements/base.txt # -r requirements/test.in @@ -163,6 +163,7 @@ diff-cover==6.4.2 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg # edx-auth-backends # edx-django-release-util # edx-django-sites-extensions @@ -221,8 +222,6 @@ django-phonenumber-field==2.0.1 # via # -r requirements/base.txt # django-oscar -django-rest-swagger==2.2.0 - # via -r requirements/base.txt django-simple-history==3.0.0 # via -r requirements/base.txt django-solo==1.2.0 @@ -253,11 +252,11 @@ djangorestframework==3.12.4 # via # -r requirements/base.txt # django-config-models - # django-rest-swagger # djangorestframework-csv # djangorestframework-datatables # drf-extensions # drf-jwt + # drf-yasg # edx-drf-extensions # rest-condition djangorestframework-csv==2.1.1 @@ -270,6 +269,8 @@ drf-jwt==1.19.1 # via # -r requirements/base.txt # edx-drf-extensions +drf-yasg==1.20.0 + # via -r requirements/base.txt edx-auth-backends==3.4.0 # via # -c requirements/pins.txt @@ -358,8 +359,14 @@ importlib-metadata==4.8.1 # via # -r requirements/e2e.txt # pytest-randomly -inflect==5.3.0 - # via jinja2-pluralize +inflection==0.5.1 + # via + # -r requirements/base.txt + # drf-yasg +iniconfig==1.1.1 + # via + # -r requirements/e2e.txt + # pytest ipaddress==1.0.23 # via # -r requirements/base.txt @@ -470,16 +477,13 @@ oauthlib==3.1.1 # -r requirements/base.txt # requests-oauthlib # social-auth-core -openapi-codec==1.3.2 - # via - # -r requirements/base.txt - # django-rest-swagger -packaging==21.0 +packaging==21.3 # via # -r requirements/base.txt # -r requirements/e2e.txt # -r requirements/tox.txt # bleach + # drf-yasg # pytest # tox paramiko==2.7.2 @@ -763,7 +767,15 @@ rsa==4.7.2 # via # -r requirements/base.txt # cybersource-rest-client-python -rules==3.0 +ruamel.yaml==0.17.21 + # via + # -r requirements/base.txt + # drf-yasg +ruamel.yaml.clib==0.2.6 + # via + # -r requirements/base.txt + # ruamel.yaml +rules==3.1 # via -r requirements/base.txt s3transfer==0.5.0 # via @@ -784,10 +796,6 @@ shellescape==3.8.1 # -r requirements/base.txt # crypto # cybersource-rest-client-python -simplejson==3.17.5 - # via - # -r requirements/base.txt - # django-rest-swagger six==1.16.0 # via # -r requirements/base.txt @@ -903,7 +911,8 @@ uritemplate==3.0.1 # via # -r requirements/base.txt # coreapi -urllib3==1.26.7 + # drf-yasg +urllib3==1.26.8 # via # -c requirements/pins.txt # -r requirements/base.txt