From 1d9a5ab4e776dde7b1d7ef9bc314708cc766957b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Fri, 27 Sep 2019 18:10:44 +0200 Subject: [PATCH] Rename `swagger_auto_schema` decorator --- lms/djangoapps/certificates/apis/v0/views.py | 4 ++-- openedx/core/djangoapps/bookmarks/views.py | 8 ++++---- openedx/core/openapi.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lms/djangoapps/certificates/apis/v0/views.py b/lms/djangoapps/certificates/apis/v0/views.py index f3f0b516e2..45d3ced28e 100644 --- a/lms/djangoapps/certificates/apis/v0/views.py +++ b/lms/djangoapps/certificates/apis/v0/views.py @@ -20,7 +20,7 @@ from openedx.core.djangoapps.certificates.api import certificates_viewable_for_c from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from openedx.core.djangoapps.user_api.accounts.api import visible_fields from openedx.core.lib.api.authentication import OAuth2AuthenticationAllowInactiveUser -from openedx.core.openapi import swagger_auto_schema, openapi +from openedx.core.openapi import document_api_view, openapi log = logging.getLogger(__name__) @@ -154,7 +154,7 @@ class CertificatesListView(GenericAPIView): required_scopes = ['certificates:read'] - @swagger_auto_schema(manual_parameters=[ + @document_api_view(manual_parameters=[ openapi.Parameter( 'username', openapi.IN_PATH, diff --git a/openedx/core/djangoapps/bookmarks/views.py b/openedx/core/djangoapps/bookmarks/views.py index 904f1f092b..a98c277e81 100644 --- a/openedx/core/djangoapps/bookmarks/views.py +++ b/openedx/core/djangoapps/bookmarks/views.py @@ -26,7 +26,7 @@ from rest_framework_oauth.authentication import OAuth2Authentication from openedx.core.djangoapps.bookmarks.api import BookmarksLimitReachedError from openedx.core.lib.api.permissions import IsUserInUrl from openedx.core.lib.url_utils import unquote_slashes -from openedx.core.openapi import swagger_auto_schema, openapi +from openedx.core.openapi import document_api_view, openapi from xmodule.modulestore.exceptions import ItemNotFoundError from . import DEFAULT_FIELDS, OPTIONAL_FIELDS, api @@ -104,7 +104,7 @@ class BookmarksListView(ListCreateAPIView, BookmarksViewMixin): permission_classes = (permissions.IsAuthenticated,) serializer_class = BookmarkSerializer - @swagger_auto_schema( + @document_api_view( manual_parameters=[ openapi.Parameter( 'course_id', @@ -204,7 +204,7 @@ class BookmarksListView(ListCreateAPIView, BookmarksViewMixin): return page - @swagger_auto_schema + @document_api_view def post(self, request, *unused_args, **unused_kwargs): """Create a new bookmark for a user. @@ -313,7 +313,7 @@ class BookmarksDetailView(APIView, BookmarksViewMixin): log.error(error_message) return self.error_response(error_message, error_status=status.HTTP_404_NOT_FOUND) - @swagger_auto_schema( + @document_api_view( operation_summary="Get a specific bookmark for a user.", operation_description=u""" # Example Requests diff --git a/openedx/core/openapi.py b/openedx/core/openapi.py index a58aa6085a..2a7087168e 100644 --- a/openedx/core/openapi.py +++ b/openedx/core/openapi.py @@ -44,7 +44,7 @@ def dedent(text): return textwrap.dedent(text) -def swagger_auto_schema(*args, **kwargs): +def document_api_view(*args, **kwargs): """ Decorator for documenting an OpenAPI endpoint. @@ -58,7 +58,7 @@ def swagger_auto_schema(*args, **kwargs): if args: if callable(args[0]): # decorator may be used with no argument - return swagger_auto_schema(*args[1:], **kwargs)(args[0]) + return document_api_view(*args[1:], **kwargs)(args[0]) raise ValueError("Unsupported positional arguments") for param in kwargs.get('manual_parameters', ()):