Skip to content

Commit 58330bb

Browse files
committed
fix: swagger auto doc errors
1 parent 188d4ef commit 58330bb

File tree

8 files changed

+45
-3
lines changed

8 files changed

+45
-3
lines changed

cms/djangoapps/api/v1/views/course_runs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CourseRunViewSet(viewsets.GenericViewSet): # lint-amnesty, pylint: disabl
2323
lookup_value_regex = settings.COURSE_KEY_REGEX
2424
permission_classes = (permissions.IsAdminUser,)
2525
serializer_class = CourseRunSerializer
26+
queryset = []
2627

2728
def get_object(self):
2829
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field

cms/djangoapps/contentstore/api/views/course_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class CourseImportView(CourseImportExportViewMixin, GenericAPIView):
106106
# TODO: ARCH-91
107107
# This view is excluded from Swagger doc generation because it
108108
# does not specify a serializer class.
109-
exclude_from_schema = True
109+
swagger_schema = None
110110

111111
@course_author_access_required
112112
def post(self, request, course_key):

cms/djangoapps/contentstore/api/views/course_quality.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
7777
* mode
7878
7979
"""
80+
# TODO: ARCH-91
81+
# This view is excluded from Swagger doc generation because it
82+
# does not specify a serializer class.
83+
swagger_schema = None
84+
8085
@course_author_access_required
8186
def get(self, request, course_key):
8287
"""

cms/djangoapps/contentstore/api/views/course_validation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
6565
* has_proctoring_escalation_email - whether the course has a proctoring escalation email
6666
6767
"""
68+
# TODO: ARCH-91
69+
# This view is excluded from Swagger doc generation because it
70+
# does not specify a serializer class.
71+
swagger_schema = None
72+
6873
@course_author_access_required
6974
def get(self, request, course_key):
7075
"""

cms/djangoapps/contentstore/rest_api/v0/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
authoring_videos.VideoEncodingsDownloadView.as_view(), name='cms_api_videos_encodings'
6464
),
6565
re_path(
66-
fr'grading/{settings.COURSE_ID_PATTERN}',
66+
fr'grading/{settings.COURSE_ID_PATTERN}$',
6767
AuthoringGradingView.as_view(), name='cms_api_update_grading'
6868
),
6969
path(

cms/djangoapps/contentstore/rest_api/v0/views/authoring_videos.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ class VideoEncodingsDownloadView(DeveloperErrorViewMixin, RetrieveAPIView):
128128
course_key: required argument, needed to authorize course authors and identify relevant videos.
129129
"""
130130

131+
# TODO: ARCH-91
132+
# This view is excluded from Swagger doc generation because it
133+
# does not specify a serializer class.
134+
swagger_schema = None
135+
131136
def dispatch(self, request, *args, **kwargs):
132137
# TODO: probably want to refactor this to a decorator.
133138
"""
@@ -151,6 +156,11 @@ class VideoFeaturesView(DeveloperErrorViewMixin, RetrieveAPIView):
151156
public rest API endpoint providing a list of enabled video features.
152157
"""
153158

159+
# TODO: ARCH-91
160+
# This view is excluded from Swagger doc generation because it
161+
# does not specify a serializer class.
162+
swagger_schema = None
163+
154164
def dispatch(self, request, *args, **kwargs):
155165
# TODO: probably want to refactor this to a decorator.
156166
"""

cms/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
contentstore_views.textbooks_detail_handler, name='textbooks_detail_handler'),
169169
re_path(fr'^videos/{settings.COURSE_KEY_PATTERN}(?:/(?P<edx_video_id>[-\w]+))?$',
170170
contentstore_views.videos_handler, name='videos_handler'),
171-
re_path(fr'^generate_video_upload_link/{settings.COURSE_KEY_PATTERN}',
171+
re_path(fr'^generate_video_upload_link/{settings.COURSE_KEY_PATTERN}$',
172172
contentstore_views.generate_video_upload_link_handler, name='generate_video_upload_link'),
173173
re_path(fr'^video_images/{settings.COURSE_KEY_PATTERN}(?:/(?P<edx_video_id>[-\w]+))?$',
174174
contentstore_views.video_images_handler, name='video_images_handler'),

openedx/core/djangoapps/content_libraries/views.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
from django.views.decorators.clickjacking import xframe_options_exempt
8282
from django.views.decorators.csrf import csrf_exempt
8383
from django.views.generic.base import TemplateResponseMixin, View
84+
from drf_yasg.utils import swagger_auto_schema
8485
from pylti1p3.contrib.django import DjangoCacheDataStorage, DjangoDbToolConf, DjangoMessageLaunch, DjangoOIDCLogin
8586
from pylti1p3.exception import LtiException, OIDCException
8687

@@ -201,8 +202,10 @@ class LibraryRootView(GenericAPIView):
201202
"""
202203
Views to list, search for, and create content libraries.
203204
"""
205+
serializer_class = ContentLibraryMetadataSerializer
204206

205207
@apidocs.schema(
208+
responses={200: ContentLibraryMetadataSerializer(many=True)},
206209
parameters=[
207210
*LibraryApiPaginationDocs.apidoc_params,
208211
apidocs.query_parameter(
@@ -530,7 +533,13 @@ class LibraryPasteClipboardView(GenericAPIView):
530533
"""
531534
Paste content of clipboard into Library.
532535
"""
536+
serializer_class = LibraryXBlockMetadataSerializer
537+
533538
@convert_exceptions
539+
@swagger_auto_schema(
540+
request_body=LibraryPasteClipboardSerializer,
541+
responses={200: LibraryXBlockMetadataSerializer}
542+
)
534543
def post(self, request, lib_key_str):
535544
"""
536545
Import the contents of the user's clipboard and paste them into the Library
@@ -558,6 +567,7 @@ class LibraryBlocksView(GenericAPIView):
558567
"""
559568
Views to work with XBlocks in a specific content library.
560569
"""
570+
serializer_class = LibraryXBlockMetadataSerializer
561571

562572
@apidocs.schema(
563573
parameters=[
@@ -595,6 +605,10 @@ def get(self, request, lib_key_str):
595605
return self.get_paginated_response(serializer.data)
596606

597607
@convert_exceptions
608+
@swagger_auto_schema(
609+
request_body=LibraryXBlockCreationSerializer,
610+
responses={200: LibraryXBlockMetadataSerializer}
611+
)
598612
def post(self, request, lib_key_str):
599613
"""
600614
Add a new XBlock to this content library
@@ -870,6 +884,9 @@ class LibraryImportTaskViewSet(GenericViewSet):
870884
Import blocks from Courseware through modulestore.
871885
"""
872886

887+
queryset = []
888+
serializer_class = ContentLibraryBlockImportTaskSerializer
889+
873890
@convert_exceptions
874891
def list(self, request, lib_key_str):
875892
"""
@@ -889,6 +906,10 @@ def list(self, request, lib_key_str):
889906
)
890907

891908
@convert_exceptions
909+
@swagger_auto_schema(
910+
request_body=ContentLibraryBlockImportTaskCreateSerializer,
911+
responses={200: ContentLibraryBlockImportTaskSerializer}
912+
)
892913
def create(self, request, lib_key_str):
893914
"""
894915
Create and queue an import tasks for this library.

0 commit comments

Comments
 (0)