Skip to content

Commit

Permalink
fix: swagger docs ref_name conflicts (#36189)
Browse files Browse the repository at this point in the history
* fix: swagger docs ref_name conflicts

* fix: swagger auto doc errors

* chore: bumps openedx-learning==0.18.2

---------

Co-authored-by: Jillian Vogel <[email protected]>
  • Loading branch information
navinkarkera and pomegranited authored Jan 30, 2025
1 parent 0ea4bae commit 5e51e2d
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 8 deletions.
1 change: 1 addition & 0 deletions cms/djangoapps/api/v1/views/course_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CourseRunViewSet(viewsets.GenericViewSet): # lint-amnesty, pylint: disabl
lookup_value_regex = settings.COURSE_KEY_REGEX
permission_classes = (permissions.IsAdminUser,)
serializer_class = CourseRunSerializer
queryset = []

def get_object(self):
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/api/views/course_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class CourseImportView(CourseImportExportViewMixin, GenericAPIView):
# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
exclude_from_schema = True
swagger_schema = None

@course_author_access_required
def post(self, request, course_key):
Expand Down
5 changes: 5 additions & 0 deletions cms/djangoapps/contentstore/api/views/course_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
* mode
"""
# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
swagger_schema = None

@course_author_access_required
def get(self, request, course_key):
"""
Expand Down
5 changes: 5 additions & 0 deletions cms/djangoapps/contentstore/api/views/course_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
* has_proctoring_escalation_email - whether the course has a proctoring escalation email
"""
# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
swagger_schema = None

@course_author_access_required
def get(self, request, course_key):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ class GradersSerializer(serializers.Serializer):
weight = serializers.IntegerField()
id = serializers.IntegerField()

class Meta:
ref_name = "authoring_grading.Graders.v0"


class CourseGradingModelSerializer(serializers.Serializer):
""" Serializer for course grading model data """
graders = GradersSerializer(many=True, allow_null=True, allow_empty=True)

class Meta:
ref_name = "authoring_grading.CourseGrading.v0"
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/rest_api/v0/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
authoring_videos.VideoEncodingsDownloadView.as_view(), name='cms_api_videos_encodings'
),
re_path(
fr'grading/{settings.COURSE_ID_PATTERN}',
fr'grading/{settings.COURSE_ID_PATTERN}$',
AuthoringGradingView.as_view(), name='cms_api_update_grading'
),
path(
Expand Down
10 changes: 10 additions & 0 deletions cms/djangoapps/contentstore/rest_api/v0/views/authoring_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ class VideoEncodingsDownloadView(DeveloperErrorViewMixin, RetrieveAPIView):
course_key: required argument, needed to authorize course authors and identify relevant videos.
"""

# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
swagger_schema = None

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
Expand All @@ -151,6 +156,11 @@ class VideoFeaturesView(DeveloperErrorViewMixin, RetrieveAPIView):
public rest API endpoint providing a list of enabled video features.
"""

# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
swagger_schema = None

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
Expand Down
2 changes: 1 addition & 1 deletion cms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
contentstore_views.textbooks_detail_handler, name='textbooks_detail_handler'),
re_path(fr'^videos/{settings.COURSE_KEY_PATTERN}(?:/(?P<edx_video_id>[-\w]+))?$',
contentstore_views.videos_handler, name='videos_handler'),
re_path(fr'^generate_video_upload_link/{settings.COURSE_KEY_PATTERN}',
re_path(fr'^generate_video_upload_link/{settings.COURSE_KEY_PATTERN}$',
contentstore_views.generate_video_upload_link_handler, name='generate_video_upload_link'),
re_path(fr'^video_images/{settings.COURSE_KEY_PATTERN}(?:/(?P<edx_video_id>[-\w]+))?$',
contentstore_views.video_images_handler, name='video_images_handler'),
Expand Down
21 changes: 21 additions & 0 deletions openedx/core/djangoapps/content_libraries/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
from django.views.decorators.clickjacking import xframe_options_exempt
from django.views.decorators.csrf import csrf_exempt
from django.views.generic.base import TemplateResponseMixin, View
from drf_yasg.utils import swagger_auto_schema
from pylti1p3.contrib.django import DjangoCacheDataStorage, DjangoDbToolConf, DjangoMessageLaunch, DjangoOIDCLogin
from pylti1p3.exception import LtiException, OIDCException

Expand Down Expand Up @@ -201,8 +202,10 @@ class LibraryRootView(GenericAPIView):
"""
Views to list, search for, and create content libraries.
"""
serializer_class = ContentLibraryMetadataSerializer

@apidocs.schema(
responses={200: ContentLibraryMetadataSerializer(many=True)},
parameters=[
*LibraryApiPaginationDocs.apidoc_params,
apidocs.query_parameter(
Expand Down Expand Up @@ -530,7 +533,13 @@ class LibraryPasteClipboardView(GenericAPIView):
"""
Paste content of clipboard into Library.
"""
serializer_class = LibraryXBlockMetadataSerializer

@convert_exceptions
@swagger_auto_schema(
request_body=LibraryPasteClipboardSerializer,
responses={200: LibraryXBlockMetadataSerializer}
)
def post(self, request, lib_key_str):
"""
Import the contents of the user's clipboard and paste them into the Library
Expand Down Expand Up @@ -558,6 +567,7 @@ class LibraryBlocksView(GenericAPIView):
"""
Views to work with XBlocks in a specific content library.
"""
serializer_class = LibraryXBlockMetadataSerializer

@apidocs.schema(
parameters=[
Expand Down Expand Up @@ -595,6 +605,10 @@ def get(self, request, lib_key_str):
return self.get_paginated_response(serializer.data)

@convert_exceptions
@swagger_auto_schema(
request_body=LibraryXBlockCreationSerializer,
responses={200: LibraryXBlockMetadataSerializer}
)
def post(self, request, lib_key_str):
"""
Add a new XBlock to this content library
Expand Down Expand Up @@ -870,6 +884,9 @@ class LibraryImportTaskViewSet(GenericViewSet):
Import blocks from Courseware through modulestore.
"""

queryset = [] # type: ignore[assignment]
serializer_class = ContentLibraryBlockImportTaskSerializer

@convert_exceptions
def list(self, request, lib_key_str):
"""
Expand All @@ -889,6 +906,10 @@ def list(self, request, lib_key_str):
)

@convert_exceptions
@swagger_auto_schema(
request_body=ContentLibraryBlockImportTaskCreateSerializer,
responses={200: ContentLibraryBlockImportTaskSerializer}
)
def create(self, request, lib_key_str):
"""
Create and queue an import tasks for this library.
Expand Down
2 changes: 1 addition & 1 deletion requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ optimizely-sdk<5.0
# Date: 2023-09-18
# pinning this version to avoid updates while the library is being developed
# Issue for unpinning: https://github.com/openedx/edx-platform/issues/35269
openedx-learning==0.18.1
openedx-learning==0.18.2

# Date: 2023-11-29
# Open AI version 1.0.0 dropped support for openai.ChatCompletion which is currently in use in enterprise.
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ openedx-filters==1.12.0
# ora2
openedx-forum==0.1.6
# via -r requirements/edx/kernel.in
openedx-learning==0.18.1
openedx-learning==0.18.2
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/kernel.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ openedx-forum==0.1.6
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
openedx-learning==0.18.1
openedx-learning==0.18.2
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/doc.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ openedx-filters==1.12.0
# ora2
openedx-forum==0.1.6
# via -r requirements/edx/base.txt
openedx-learning==0.18.1
openedx-learning==0.18.2
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ openedx-filters==1.12.0
# ora2
openedx-forum==0.1.6
# via -r requirements/edx/base.txt
openedx-learning==0.18.1
openedx-learning==0.18.2
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
Expand Down

0 comments on commit 5e51e2d

Please sign in to comment.