Skip to content

Commit

Permalink
docs: correct swaggerfile for authoring api
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperhodge committed Nov 3, 2023
1 parent 2d0c205 commit 316a91c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,7 @@
'DESCRIPTION': 'Experimental API to edit xblocks and course content. Danger: Do not use on running courses!',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
'PREPROCESSING_HOOKS': ['cms.lib.spectacular.cms_api_filter'], # restrict spectacular to CMS API endpoints
'PREPROCESSING_HOOKS': ['cms.lib.spectacular.cms_api_filter'], # restrict spectacular to CMS API endpoints. (cms/lib/spectacular.py)
}


Expand Down
10 changes: 6 additions & 4 deletions cms/lib/spectacular.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ def cms_api_filter(endpoints):
for (path, path_regex, method, callback) in endpoints:
# Add only paths to the list that are part of the CMS API
if (
path.startswith("/api/contentstore/v1/xblock") or
path.startswith("/api/contentstore/v1/videos") or
path.startswith("/api/contentstore/v1/video_transcripts") or
path.startswith("/api/contentstore/v1/file_assets")
# Don't just replace this with /v1 when switching to a later version of the CMS API.
# That would include some unintended endpoints.
path.startswith("/api/contentstore/v0/xblock") or
path.startswith("/api/contentstore/v0/videos") or
path.startswith("/api/contentstore/v0/video_transcripts") or
path.startswith("/api/contentstore/v0/file_assets")
):
filtered.append((path, path_regex, method, callback))
return filtered
5 changes: 4 additions & 1 deletion cms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@
path('api/content_tagging/', include(('openedx.core.djangoapps.content_tagging.urls', 'content_tagging'))),
]

# studio-content-api specific API docs (using drf-spectacular and openapi-v3)
# Authoring-api specific API docs (using drf-spectacular and openapi-v3).
# This is separate from and in addition to the full studio swagger documentation already existing at /api-docs.
# Custom settings are provided in SPECTACULAR_SETTINGS in cms/envs/common.py.
# Filter function in cms/lib/spectacular.py determines paths that are swagger-documented.
urlpatterns += [
re_path('^cms-api/ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
re_path('^cms-api/schema/', SpectacularAPIView.as_view(), name='schema'),
Expand Down

0 comments on commit 316a91c

Please sign in to comment.