From b5e4ff71dd1d4926d2fbacebba11b3180015caeb Mon Sep 17 00:00:00 2001 From: Eric Herrera Date: Thu, 14 Oct 2021 08:44:27 -0500 Subject: [PATCH] chore: switch to drf-yasg Move from django-rest-swagger to drf-yasg and edx_api_doc_tools. --- designer/settings/base.py | 3 ++- designer/urls.py | 14 +++++++++-- requirements/base.in | 3 ++- requirements/base.txt | 39 ++++++++++++++++++++--------- requirements/dev.txt | 42 ++++++++++++++++++++----------- requirements/doc.txt | 42 ++++++++++++++++++++----------- requirements/production.txt | 50 ++++++++++++++++++++++++++----------- requirements/quality.txt | 42 ++++++++++++++++++++----------- requirements/test.txt | 47 +++++++++++++++++++++++----------- 9 files changed, 194 insertions(+), 88 deletions(-) diff --git a/designer/settings/base.py b/designer/settings/base.py index 9fc99399..4659fecf 100644 --- a/designer/settings/base.py +++ b/designer/settings/base.py @@ -29,9 +29,10 @@ ) THIRD_PARTY_APPS = ( + 'drf_yasg', + 'edx_api_doc_tools', 'release_util', 'rest_framework', - 'rest_framework_swagger', 'social_django', 'waffle', 'modelcluster', diff --git a/designer/urls.py b/designer/urls.py index f77187e3..6b0d4c6d 100644 --- a/designer/urls.py +++ b/designer/urls.py @@ -21,7 +21,9 @@ from django.conf.urls.static import static from django.contrib import admin from django.views.generic import RedirectView -from rest_framework_swagger.views import get_swagger_view +from drf_yasg.views import get_schema_view +from edx_api_doc_tools import make_api_info +from rest_framework import permissions from wagtail.admin import urls as wagtailadmin_urls from wagtail.documents import urls as wagtaildocs_urls from wagtail.core import urls as wagtail_urls @@ -31,9 +33,17 @@ admin.autodiscover() + +api_info = make_api_info(title="designer API", version="v1") +schema_view = get_schema_view( + api_info, + public=False, + permission_classes=(permissions.AllowAny,), +) + urlpatterns = oauth2_urlpatterns + [ url(r'^api/', include('designer.apps.api.urls')), - url(r'^api-docs/', get_swagger_view(title='designer API')), + url(r'^api-docs/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), # Use the same auth views for all logins, including those originating from the browseable API. url(r'^api-auth/', include(oauth2_urlpatterns)), url(r'^auto_auth/$', core_views.AutoAuth.as_view(), name='auto_auth'), diff --git a/requirements/base.in b/requirements/base.in index 960dea7d..49a655ac 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -6,10 +6,11 @@ Django # Web application framework django-cors-headers django-extensions -django-rest-swagger django-storages django-waffle djangorestframework +drf-yasg +edx-api-doc-tools edx-auth-backends edx-django-release-util edx-django-utils diff --git a/requirements/base.txt b/requirements/base.txt index c6de7acf..98beb0ba 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -17,11 +17,11 @@ cffi==1.15.0 charset-normalizer==2.0.7 # via requests coreapi==2.3.3 - # via - # django-rest-swagger - # openapi-codec + # via drf-yasg coreschema==0.0.4 - # via coreapi + # via + # coreapi + # drf-yasg cryptography==35.0.0 # via # pyjwt @@ -43,6 +43,8 @@ django==3.2.8 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-auth-backends # edx-django-release-util # edx-django-utils @@ -58,8 +60,6 @@ django-filter==2.4.0 # via wagtail django-modelcluster==5.2 # via wagtail -django-rest-swagger==2.2.0 - # via -r requirements/base.in django-storages==1.12.2 # via -r requirements/base.in django-taggit==1.5.1 @@ -74,14 +74,21 @@ django-waffle==2.2.1 djangorestframework==3.12.4 # via # -r requirements/base.in - # django-rest-swagger # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-drf-extensions # wagtail draftjs-exporter==2.1.7 # via wagtail drf-jwt==1.19.1 # via edx-drf-extensions +drf-yasg==1.20.0 + # via + # -r requirements/base.in + # edx-api-doc-tools +edx-api-doc-tools==1.5.0 + # via -r requirements/base.in edx-auth-backends==4.0.0 # via -r requirements/base.in edx-django-release-util==1.1.0 @@ -109,6 +116,8 @@ idna==3.3 # via requests inflect==5.3.0 # via -r requirements/base.in +inflection==0.5.1 + # via drf-yasg itypes==1.2.0 # via coreapi jinja2==3.0.2 @@ -127,10 +136,10 @@ oauthlib==3.1.1 # via # requests-oauthlib # social-auth-core -openapi-codec==1.3.2 - # via django-rest-swagger openpyxl==3.0.9 # via tablib +packaging==21.0 + # via drf-yasg pbr==5.6.0 # via stevedore pillow==8.4.0 @@ -152,6 +161,8 @@ pyjwt[crypto]==2.3.0 # social-auth-core pymongo==3.12.1 # via edx-opaque-keys +pyparsing==2.4.7 + # via packaging python-dateutil==2.8.2 # via # -r requirements/base.in @@ -178,10 +189,12 @@ requests==2.26.0 # wagtail requests-oauthlib==1.3.0 # via social-auth-core +ruamel.yaml==0.17.16 + # via drf-yasg +ruamel.yaml.clib==0.2.6 + # via ruamel.yaml semantic-version==2.8.5 # via edx-drf-extensions -simplejson==3.17.5 - # via django-rest-swagger six==1.16.0 # via # edx-auth-backends @@ -215,7 +228,9 @@ tablib[xls,xlsx]==3.0.0 telepath==0.2 # via wagtail uritemplate==4.1.1 - # via coreapi + # via + # coreapi + # drf-yasg urllib3==1.26.7 # via requests wagtail==2.13.4 diff --git a/requirements/dev.txt b/requirements/dev.txt index 30270d26..17369dc4 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -64,12 +64,12 @@ codecov==2.1.12 coreapi==2.3.3 # via # -r requirements/quality.txt - # django-rest-swagger - # openapi-codec + # drf-yasg coreschema==0.0.4 # via # -r requirements/quality.txt # coreapi + # drf-yasg coverage[toml]==6.0.2 # via # -r requirements/quality.txt @@ -107,6 +107,8 @@ django==3.2.8 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-auth-backends # edx-django-release-util # edx-django-utils @@ -133,8 +135,6 @@ django-modelcluster==5.2 # via # -r requirements/quality.txt # wagtail -django-rest-swagger==2.2.0 - # via -r requirements/quality.txt django-storages==1.12.2 # via -r requirements/quality.txt django-taggit==1.5.1 @@ -153,8 +153,9 @@ django-waffle==2.2.1 djangorestframework==3.12.4 # via # -r requirements/quality.txt - # django-rest-swagger # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-drf-extensions # wagtail draftjs-exporter==2.1.7 @@ -165,6 +166,12 @@ drf-jwt==1.19.1 # via # -r requirements/quality.txt # edx-drf-extensions +drf-yasg==1.20.0 + # via + # -r requirements/quality.txt + # edx-api-doc-tools +edx-api-doc-tools==1.5.0 + # via -r requirements/quality.txt edx-auth-backends==4.0.0 # via -r requirements/quality.txt edx-django-release-util==1.1.0 @@ -194,7 +201,7 @@ et-xmlfile==1.1.0 # openpyxl factory-boy==3.2.0 # via -r requirements/quality.txt -faker==9.5.0 +faker==9.5.1 # via # -r requirements/quality.txt # factory-boy @@ -219,6 +226,10 @@ inflect==5.3.0 # via # -r requirements/quality.txt # jinja2-pluralize +inflection==0.5.1 + # via + # -r requirements/quality.txt + # drf-yasg iniconfig==1.1.1 # via # -r requirements/quality.txt @@ -269,10 +280,6 @@ oauthlib==3.1.1 # -r requirements/quality.txt # requests-oauthlib # social-auth-core -openapi-codec==1.3.2 - # via - # -r requirements/quality.txt - # django-rest-swagger openpyxl==3.0.9 # via # -r requirements/quality.txt @@ -280,6 +287,7 @@ openpyxl==3.0.9 packaging==21.0 # via # -r requirements/quality.txt + # drf-yasg # pytest # tox path==16.2.0 @@ -424,14 +432,18 @@ requests-oauthlib==1.3.0 # via # -r requirements/quality.txt # social-auth-core -semantic-version==2.8.5 +ruamel.yaml==0.17.16 # via # -r requirements/quality.txt - # edx-drf-extensions -simplejson==3.17.5 + # drf-yasg +ruamel.yaml.clib==0.2.6 # via # -r requirements/quality.txt - # django-rest-swagger + # ruamel.yaml +semantic-version==2.8.5 + # via + # -r requirements/quality.txt + # edx-drf-extensions six==1.16.0 # via # -r requirements/quality.txt @@ -509,11 +521,13 @@ typing-extensions==3.10.0.2 # via # -r requirements/quality.txt # astroid + # faker # pylint uritemplate==4.1.1 # via # -r requirements/quality.txt # coreapi + # drf-yasg urllib3==1.26.7 # via # -r requirements/quality.txt diff --git a/requirements/doc.txt b/requirements/doc.txt index dfec1f51..b4ce789e 100644 --- a/requirements/doc.txt +++ b/requirements/doc.txt @@ -66,12 +66,12 @@ codecov==2.1.12 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 + # drf-yasg coverage[toml]==6.0.2 # via # -r requirements/test.txt @@ -103,6 +103,8 @@ django==3.2.8 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-auth-backends # edx-django-release-util # edx-django-utils @@ -126,8 +128,6 @@ django-modelcluster==5.2 # via # -r requirements/test.txt # wagtail -django-rest-swagger==2.2.0 - # via -r requirements/test.txt django-storages==1.12.2 # via -r requirements/test.txt django-taggit==1.5.1 @@ -146,8 +146,9 @@ django-waffle==2.2.1 djangorestframework==3.12.4 # via # -r requirements/test.txt - # django-rest-swagger # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-drf-extensions # wagtail doc8==0.9.1 @@ -166,6 +167,12 @@ drf-jwt==1.19.1 # via # -r requirements/test.txt # edx-drf-extensions +drf-yasg==1.20.0 + # via + # -r requirements/test.txt + # edx-api-doc-tools +edx-api-doc-tools==1.5.0 + # via -r requirements/test.txt edx-auth-backends==4.0.0 # via -r requirements/test.txt edx-django-release-util==1.1.0 @@ -193,7 +200,7 @@ et-xmlfile==1.1.0 # openpyxl factory-boy==3.2.0 # via -r requirements/test.txt -faker==9.5.0 +faker==9.5.1 # via # -r requirements/test.txt # factory-boy @@ -218,6 +225,10 @@ imagesize==1.2.0 # via sphinx inflect==5.3.0 # via -r requirements/test.txt +inflection==0.5.1 + # via + # -r requirements/test.txt + # drf-yasg iniconfig==1.1.1 # via # -r requirements/test.txt @@ -265,10 +276,6 @@ 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 openpyxl==3.0.9 # via # -r requirements/test.txt @@ -277,6 +284,7 @@ packaging==21.0 # via # -r requirements/test.txt # bleach + # drf-yasg # pytest # sphinx # tox @@ -415,14 +423,18 @@ requests-oauthlib==1.3.0 # social-auth-core restructuredtext-lint==1.3.2 # via doc8 -semantic-version==2.8.5 +ruamel.yaml==0.17.16 # via # -r requirements/test.txt - # edx-drf-extensions -simplejson==3.17.5 + # drf-yasg +ruamel.yaml.clib==0.2.6 # via # -r requirements/test.txt - # django-rest-swagger + # ruamel.yaml +semantic-version==2.8.5 + # via + # -r requirements/test.txt + # edx-drf-extensions six==1.16.0 # via # -r requirements/test.txt @@ -514,11 +526,13 @@ typing-extensions==3.10.0.2 # via # -r requirements/test.txt # astroid + # faker # pylint uritemplate==4.1.1 # via # -r requirements/test.txt # coreapi + # drf-yasg urllib3==1.26.7 # via # -r requirements/test.txt diff --git a/requirements/production.txt b/requirements/production.txt index 14c237ef..43e1be3e 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -16,9 +16,9 @@ beautifulsoup4==4.9.3 # via # -r requirements/base.txt # wagtail -boto3==1.18.65 +boto3==1.19.0 # via -r requirements/production.in -botocore==1.21.65 +botocore==1.22.0 # via # boto3 # s3transfer @@ -37,12 +37,12 @@ charset-normalizer==2.0.7 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 + # drf-yasg cryptography==35.0.0 # via # -r requirements/base.txt @@ -65,6 +65,8 @@ django==3.2.8 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-auth-backends # edx-django-release-util # edx-django-utils @@ -86,8 +88,6 @@ django-modelcluster==5.2 # via # -r requirements/base.txt # wagtail -django-rest-swagger==2.2.0 - # via -r requirements/base.txt django-storages==1.12.2 # via -r requirements/base.txt django-taggit==1.5.1 @@ -106,8 +106,9 @@ django-waffle==2.2.1 djangorestframework==3.12.4 # via # -r requirements/base.txt - # django-rest-swagger # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-drf-extensions # wagtail draftjs-exporter==2.1.7 @@ -118,6 +119,12 @@ drf-jwt==1.19.1 # via # -r requirements/base.txt # edx-drf-extensions +drf-yasg==1.20.0 + # via + # -r requirements/base.txt + # edx-api-doc-tools +edx-api-doc-tools==1.5.0 + # via -r requirements/base.txt edx-auth-backends==4.0.0 # via -r requirements/base.txt edx-django-release-util==1.1.0 @@ -159,6 +166,10 @@ idna==3.3 # requests inflect==5.3.0 # via -r requirements/base.txt +inflection==0.5.1 + # via + # -r requirements/base.txt + # drf-yasg itypes==1.2.0 # via # -r requirements/base.txt @@ -192,14 +203,14 @@ 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 openpyxl==3.0.9 # via # -r requirements/base.txt # tablib +packaging==21.0 + # via + # -r requirements/base.txt + # drf-yasg pbr==5.6.0 # via # -r requirements/base.txt @@ -236,6 +247,10 @@ pymongo==3.12.1 # via # -r requirements/base.txt # edx-opaque-keys +pyparsing==2.4.7 + # via + # -r requirements/base.txt + # packaging python-dateutil==2.8.2 # via # -r requirements/base.txt @@ -273,16 +288,20 @@ requests-oauthlib==1.3.0 # via # -r requirements/base.txt # social-auth-core +ruamel.yaml==0.17.16 + # via + # -r requirements/base.txt + # drf-yasg +ruamel.yaml.clib==0.2.6 + # via + # -r requirements/base.txt + # ruamel.yaml s3transfer==0.5.0 # via boto3 semantic-version==2.8.5 # via # -r requirements/base.txt # edx-drf-extensions -simplejson==3.17.5 - # via - # -r requirements/base.txt - # django-rest-swagger six==1.16.0 # via # -r requirements/base.txt @@ -332,6 +351,7 @@ uritemplate==4.1.1 # via # -r requirements/base.txt # coreapi + # drf-yasg urllib3==1.26.7 # via # -r requirements/base.txt diff --git a/requirements/quality.txt b/requirements/quality.txt index 6da821e0..39d2b131 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -60,12 +60,12 @@ codecov==2.1.12 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 + # drf-yasg coverage[toml]==6.0.2 # via # -r requirements/test.txt @@ -97,6 +97,8 @@ django==3.2.8 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-auth-backends # edx-django-release-util # edx-django-utils @@ -120,8 +122,6 @@ django-modelcluster==5.2 # via # -r requirements/test.txt # wagtail -django-rest-swagger==2.2.0 - # via -r requirements/test.txt django-storages==1.12.2 # via -r requirements/test.txt django-taggit==1.5.1 @@ -140,8 +140,9 @@ django-waffle==2.2.1 djangorestframework==3.12.4 # via # -r requirements/test.txt - # django-rest-swagger # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-drf-extensions # wagtail draftjs-exporter==2.1.7 @@ -152,6 +153,12 @@ drf-jwt==1.19.1 # via # -r requirements/test.txt # edx-drf-extensions +drf-yasg==1.20.0 + # via + # -r requirements/test.txt + # edx-api-doc-tools +edx-api-doc-tools==1.5.0 + # via -r requirements/test.txt edx-auth-backends==4.0.0 # via -r requirements/test.txt edx-django-release-util==1.1.0 @@ -179,7 +186,7 @@ et-xmlfile==1.1.0 # openpyxl factory-boy==3.2.0 # via -r requirements/test.txt -faker==9.5.0 +faker==9.5.1 # via # -r requirements/test.txt # factory-boy @@ -202,6 +209,10 @@ idna==3.3 # requests inflect==5.3.0 # via -r requirements/test.txt +inflection==0.5.1 + # via + # -r requirements/test.txt + # drf-yasg iniconfig==1.1.1 # via # -r requirements/test.txt @@ -249,10 +260,6 @@ 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 openpyxl==3.0.9 # via # -r requirements/test.txt @@ -260,6 +267,7 @@ openpyxl==3.0.9 packaging==21.0 # via # -r requirements/test.txt + # drf-yasg # pytest # tox pbr==5.6.0 @@ -390,14 +398,18 @@ requests-oauthlib==1.3.0 # via # -r requirements/test.txt # social-auth-core -semantic-version==2.8.5 +ruamel.yaml==0.17.16 # via # -r requirements/test.txt - # edx-drf-extensions -simplejson==3.17.5 + # drf-yasg +ruamel.yaml.clib==0.2.6 # via # -r requirements/test.txt - # django-rest-swagger + # ruamel.yaml +semantic-version==2.8.5 + # via + # -r requirements/test.txt + # edx-drf-extensions six==1.16.0 # via # -r requirements/test.txt @@ -470,11 +482,13 @@ typing-extensions==3.10.0.2 # via # -r requirements/test.txt # astroid + # faker # pylint uritemplate==4.1.1 # via # -r requirements/test.txt # coreapi + # drf-yasg urllib3==1.26.7 # via # -r requirements/test.txt diff --git a/requirements/test.txt b/requirements/test.txt index e490e58e..4480dcaf 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -52,12 +52,12 @@ codecov==2.1.12 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 + # drf-yasg coverage[toml]==6.0.2 # via # -r requirements/test.in @@ -87,6 +87,8 @@ distlib==0.3.3 # django-treebeard # djangorestframework # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-auth-backends # edx-django-release-util # edx-django-utils @@ -110,8 +112,6 @@ django-modelcluster==5.2 # via # -r requirements/base.txt # wagtail -django-rest-swagger==2.2.0 - # via -r requirements/base.txt django-storages==1.12.2 # via -r requirements/base.txt django-taggit==1.5.1 @@ -130,8 +130,9 @@ django-waffle==2.2.1 djangorestframework==3.12.4 # via # -r requirements/base.txt - # django-rest-swagger # drf-jwt + # drf-yasg + # edx-api-doc-tools # edx-drf-extensions # wagtail draftjs-exporter==2.1.7 @@ -142,6 +143,12 @@ drf-jwt==1.19.1 # via # -r requirements/base.txt # edx-drf-extensions +drf-yasg==1.20.0 + # via + # -r requirements/base.txt + # edx-api-doc-tools +edx-api-doc-tools==1.5.0 + # via -r requirements/base.txt edx-auth-backends==4.0.0 # via -r requirements/base.txt edx-django-release-util==1.1.0 @@ -169,7 +176,7 @@ et-xmlfile==1.1.0 # openpyxl factory-boy==3.2.0 # via -r requirements/test.in -faker==9.5.0 +faker==9.5.1 # via # -r requirements/test.in # factory-boy @@ -191,6 +198,10 @@ idna==3.3 # requests inflect==5.3.0 # via -r requirements/base.txt +inflection==0.5.1 + # via + # -r requirements/base.txt + # drf-yasg iniconfig==1.1.1 # via pytest isort==5.9.3 @@ -231,16 +242,14 @@ 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 openpyxl==3.0.9 # via # -r requirements/base.txt # tablib packaging==21.0 # via + # -r requirements/base.txt + # drf-yasg # pytest # tox pbr==5.6.0 @@ -306,7 +315,9 @@ pymongo==3.12.1 # -r requirements/base.txt # edx-opaque-keys pyparsing==2.4.7 - # via packaging + # via + # -r requirements/base.txt + # packaging pytest==6.2.5 # via # -r requirements/test.in @@ -354,14 +365,18 @@ requests-oauthlib==1.3.0 # via # -r requirements/base.txt # social-auth-core -semantic-version==2.8.5 +ruamel.yaml==0.17.16 # via # -r requirements/base.txt - # edx-drf-extensions -simplejson==3.17.5 + # drf-yasg +ruamel.yaml.clib==0.2.6 # via # -r requirements/base.txt - # django-rest-swagger + # ruamel.yaml +semantic-version==2.8.5 + # via + # -r requirements/base.txt + # edx-drf-extensions six==1.16.0 # via # -r requirements/base.txt @@ -427,11 +442,13 @@ tox==3.24.4 typing-extensions==3.10.0.2 # via # astroid + # faker # pylint uritemplate==4.1.1 # via # -r requirements/base.txt # coreapi + # drf-yasg urllib3==1.26.7 # via # -r requirements/base.txt