Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cms/lib/spectacular.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
from drf_spectacular.openapi import AutoSchema

# Legacy operations superseded by a conforming address under /api/authoring/.
# Each is listed in the truncated spelling as well as the full one: the routes
# make the final character optional, so both addresses resolve, and which one
# the generator emits depends on how it renders that regex.
# Regex-routed entries are listed in both the truncated and full spellings (the
# route makes the final character optional, so both addresses resolve, and which
# the generator emits depends on how it renders that regex). Exact-match entries
# (path()) appear only once.
SUPERSEDED_PATHS = (
"/api/contentstore/v0/youtube_transcripts/{course_id}/chec",
"/api/contentstore/v0/youtube_transcripts/{course_id}/check",
"/api/contentstore/v0/youtube_transcripts/{course_id}/uploa",
"/api/contentstore/v0/youtube_transcripts/{course_id}/upload",
"/api/contentstore/v1/home",
Comment thread
Faraz32123 marked this conversation as resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should deprecate this yet. The replacement it points at, /api/authoring/v3/home/, is marked x-internal, still writes a CourseCreator row on GET and ignores org, and none of that is written down in #39068 yet. Deprecating now points callers at something we don't treat as public and that has the same problem as v1.

The write on GET looks like a small fix: report unrequested when the user has no CourseCreator row instead of inserting one, and have user_requested_access create the row with get_or_create when the user actually asks for access.

Can you write the v3 fixes up in #39068 or open a PR for them? And is /api/authoring/v3/home/ meant to be public? If it is, it shouldn't be x-internal, and once it's fixed and public I'm happy to see this land.

)

# Legacy addresses of APIs migrated to /api/authoring/, marked deprecated for
Expand Down
25 changes: 25 additions & 0 deletions cms/lib/tests/test_spectacular.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,33 @@ def test_both_spellings_of_each_superseded_path_are_listed(self):
"/api/contentstore/v0/youtube_transcripts/{course_id}/check",
"/api/contentstore/v0/youtube_transcripts/{course_id}/uploa",
"/api/contentstore/v0/youtube_transcripts/{course_id}/upload",
"/api/contentstore/v1/home",
}

def test_v1_home_is_marked_deprecated_in_generated_schema(self):
"""The URL router emits the path key without a trailing slash, matching SUPERSEDED_PATHS."""
patterns = [url_path("api/contentstore/v1/home", _HomeViewSet.as_view({"get": "list"}))]
schema = SchemaGenerator(patterns=patterns).get_schema(request=None, public=True)
result = self._run(schema)
assert result["paths"]["/api/contentstore/v1/home"]["get"]["deprecated"] is True

def test_v1_home_libraries_sibling_is_not_marked_deprecated(self):
"""Exact-path lookup must not spill onto the sibling libraries path."""
home_path = "/api/contentstore/v1/home"
libraries_path = "/api/contentstore/v1/home/libraries"
result = self._run({"paths": {
home_path: {"get": {}},
libraries_path: {"get": {}},
}})
assert result["paths"][home_path]["get"]["deprecated"] is True
assert "deprecated" not in result["paths"][libraries_path]["get"]

def test_a_conforming_sibling_path_is_not_marked_deprecated(self):
"""A real path near the replacement that no entry in SUPERSEDED_PATHS covers is unchanged."""
sibling_path = "/api/authoring/v3/home/courses/"
result = self._run({"paths": {sibling_path: {"get": {}}}})
assert "deprecated" not in result["paths"][sibling_path]["get"]

def test_the_conforming_paths_are_left_unmarked(self):
conforming = "/api/authoring/v1/courses/{course_key}/youtube_transcript_checks/"
result = self._run({"paths": {conforming: {"get": {"operationId": "x"}}}})
Expand Down
Loading