Skip to content

Commit 427bb8e

Browse files
committed
feat: add openai schema tag for our versioned APIs
Add openai schema tag for our new versioned APIs for distinguishment, So that we can filter out the /auhoring-api/schema/ on the basis of tags and create/update our sdk.
1 parent 080544c commit 427bb8e

7 files changed

Lines changed: 15 additions & 5 deletions

File tree

cms/djangoapps/contentstore/rest_api/v1/views/xblock.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import logging
3434

3535
from django.http import JsonResponse
36+
from drf_spectacular.utils import extend_schema
3637
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
3738
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser
3839
from opaque_keys import InvalidKeyError
@@ -88,6 +89,7 @@ def _apply_minimal_view(response):
8889
return JsonResponse({k: v for k, v in body.items() if k in _MINIMAL_VIEW_FIELDS})
8990

9091

92+
@extend_schema(tags=["openedx-platform-sdk"])
9193
class XblockViewSet(StandardizedErrorMixin, viewsets.ViewSet):
9294
"""
9395
ViewSet for xblock CRUD operations (v1 — ADR 0028).

cms/djangoapps/contentstore/rest_api/v3/views/authoring_grading.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
)
8282

8383

84+
@extend_schema(tags=["openedx-platform-sdk"])
8485
class AuthoringGradingViewSet(StandardizedErrorMixin, viewsets.ViewSet):
8586
"""
8687
ViewSet for course grading settings (v3). Registered via DefaultRouter

cms/djangoapps/contentstore/rest_api/v3/views/course_details.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def _apply_view_preset(data, view_preset):
128128
return {key: value for key, value in data.items() if key in _MINIMAL_VIEW_FIELDS}
129129

130130

131+
@extend_schema(tags=["openedx-platform-sdk"])
131132
class CourseDetailsViewSet(StandardizedErrorMixin, viewsets.ViewSet):
132133
"""
133134
ViewSet for course details (v3). Registered via DefaultRouter (basename ``course_details``).

cms/djangoapps/contentstore/rest_api/v3/views/home.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import edx_api_doc_tools as apidocs
3030
from django.conf import settings
31+
from drf_spectacular.utils import extend_schema
3132
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
3233
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser
3334
from organizations import api as org_api
@@ -47,6 +48,7 @@
4748
from openedx.core.lib.api.mixins import StandardizedErrorMixin
4849

4950

51+
@extend_schema(tags=["openedx-platform-sdk"])
5052
class HomeViewSet(StandardizedErrorMixin, viewsets.ViewSet):
5153
"""
5254
ViewSet for the Studio home page. Registered via DefaultRouter (basename ``home``).

cms/djangoapps/contentstore/rest_api/v4/views/home.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def _maybe_set_legacy_order_deprecation_header(
9999
return response
100100

101101

102+
@extend_schema(tags=["openedx-platform-sdk"])
102103
class HomeCoursesViewSet(StandardizedErrorMixin, viewsets.ViewSet):
103104
"""
104105
ViewSet for course listing (v4). Registered via DefaultRouter (basename ``home-courses``).

cms/lib/spectacular.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55

66
def cms_api_filter(endpoints):
77
"""
8-
At the moment, we are only enabling drf-spectacular for the CMS API.
9-
Filter out endpoints that are not part of the CMS API.
8+
Pre-processing hook: keep only contentstore versioned endpoints and select
9+
course-level endpoints.
1010
"""
1111
filtered = []
12-
CMS_PATH_PATTERN = re.compile(
13-
r"^/api/contentstore/v0/(xblock|videos|video_transcripts|file_assets|youtube_transcripts)"
14-
)
12+
CMS_PATH_PATTERN = re.compile(r"^/api/contentstore/v\d+/")
1513

1614
for path, path_regex, method, callback in endpoints:
1715
if CMS_PATH_PATTERN.match(path) or (

openedx/core/djangoapps/enrollments/v2/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def _is_minimal_view_requested(request) -> bool:
196196
# EnrollmentViewSet — consolidates list / create / unenroll / allowed
197197
# ===========================================================================
198198
@can_disable_rate_limit
199+
@extend_schema(tags=["openedx-platform-sdk"])
199200
class EnrollmentViewSet(StandardizedErrorMixin, viewsets.ViewSet, ApiKeyPermissionMixIn):
200201
"""
201202
Canonical ViewSet for the v2 Enrollment API.
@@ -423,6 +424,7 @@ def allowed(self, request):
423424
# ===========================================================================
424425
# Kept as a standalone APIView because the {username},{course_id} URL form
425426
# (comma-separated, both optional) is not expressible via DefaultRouter.
427+
@extend_schema(tags=["openedx-platform-sdk"])
426428
class EnrollmentRetrieveView(StandardizedErrorMixin, ApiKeyPermissionMixIn, APIView):
427429
"""GET enrollment for a course (and optionally a named user)."""
428430

@@ -501,6 +503,7 @@ def get(self, request, course_id=None, username=None):
501503
# ===========================================================================
502504
# UserRolesView — GET /roles/ (singleton list endpoint for the current user)
503505
# ===========================================================================
506+
@extend_schema(tags=["openedx-platform-sdk"])
504507
class UserRolesView(StandardizedErrorMixin, APIView):
505508
"""List the current user's course-level roles."""
506509

@@ -574,6 +577,7 @@ def get(self, request):
574577
# ===========================================================================
575578
# CourseEnrollmentDetailView — GET /course/{course_id} (public, no auth)
576579
# ===========================================================================
580+
@extend_schema(tags=["openedx-platform-sdk"])
577581
class CourseEnrollmentDetailView(StandardizedErrorMixin, APIView):
578582
"""Get enrollment information about a particular course."""
579583

@@ -624,6 +628,7 @@ def get(self, request, course_id=None):
624628
# EnrollmentsAdminListView — GET /enrollments/ (admin paginated list)
625629
# ===========================================================================
626630
@extend_schema(
631+
tags=["openedx-platform-sdk"],
627632
summary="List all course enrollments (admin-only, paginated)",
628633
description=(
629634
"Admin-only paginated list of CourseEnrollment records, optionally filtered by "

0 commit comments

Comments
 (0)