Feat/implement sdk - #1
Open
Faraz32123 wants to merge 8 commits into
Open
Conversation
Adds the tools needed to generate the SDK from openedx-platform: - filter_schema.py: filters the full OpenAPI schema to only paths tagged with openedx-platform-sdk, resolving all transitive $ref dependencies - config.yml: openapi-python-client config (package/project name + include_tags) - README.md: documents covered APIs, regeneration steps (curl + filter + openapi-python-client generate), and usage examples Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Generated with openapi-python-client from the filtered OpenAPI schema. Covers 12 operations across 5 APIs: - XBlock v1: create, retrieve, update, partial_update, destroy - Authoring Grading v3: partial_update - Course Details v3: retrieve, update - Home v3: list, courses, libraries - Home v4: courses (paginated) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements OAuth2ClientCredentials for the OpenedX JWT auth flow:
- Fetches JWT via POST to {lms_url}/oauth2/access_token (client_credentials grant)
- Caches token and auto-refreshes 60s before expiry
- Returns AuthenticatedClient with prefix="JWT" (required by OpenedX)
Usage:
auth = OAuth2ClientCredentials(lms_url, client_id, client_secret)
with auth.get_client(studio_url) as client:
result = v3_home_list.sync(client=client)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Automates the full SDK regeneration workflow:
1. Optional branch checkout in openedx-platform
2. Download OpenAPI schema from running Studio (STUDIO_URL env var)
3. Filter schema to openedx-platform-sdk tagged paths via filter_schema.py
4. Run openapi-python-client update (or generate on first run)
Usage:
./regen_sdk.sh # uses current platform branch
./regen_sdk.sh feat/axim-api_improvements # checkout branch first
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add 'Testing Locally' section to README: install, create OAuth2 app
in LMS admin (user must be linked for JWT issuance), test script
- Fix studio_url in auth example to include /api/contentstore prefix
- Make regen_sdk.sh portable: PLATFORM_DIR env var for custom platform
path, clear error if branch requested but repo not found, STUDIO_URL
error message if Studio unreachable
- Rename v3_home_list → v3_home_retrieve: fixed HomeViewSet list action
schema to return a single StudioHome object (not array) by overriding
_is_list_view in a custom AutoSchema; generator renamed the module
accordingly
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Faraz32123
force-pushed
the
feat/implement_sdk
branch
from
June 24, 2026 11:49
fd17006 to
ad6a6ef
Compare
…and generator bug fixes
Regenerated from updated openedx-platform schemas. Three platform-side
fixes drive this regen (see companion commit on add_changes_wrt_sdk):
- Grading: grade_cutoffs, grace_period, minimum_grade_credit are now
typed fields on AuthoringGradingCourseGradingV0 and
PatchedauthoringGradingCourseGradingV0. Callers no longer need to
pass these via additional_properties["key"] = value workarounds.
New models: AuthoringGradingGracePeriodV0,
*GradeCutoffs (additionalProperties wrapper for the dict field).
- v4 Home: operation ID changed from v4_home_courses_list to
v4_home_courses_retrieve (the schema now correctly describes a
paginated object, not an array). New model PaginatedV4HomeCoursesResponse
with count, num_pages, current_page, start, next_, previous, results.
- Course details: certificate_available_date is now nullable in the
schema; CourseDetails model updated accordingly.
Generator bug fixes baked into regen_sdk.sh (applied after every regen):
- Bug 1: v3_course_details_update.py uses Unset in type annotations
but the generator only imports UNSET. Fixed with a sed post-step.
- Bug 2: _get_kwargs emits three identical isinstance(body, X) blocks
for json / form / multipart — the multipart block always wins and
breaks nested-dict payloads. Removed data/multipart blocks, kept
only the JSON block. Affects: v1_xblock_{create,update,partial_update},
v3_authoring_grading_partial_update, v3_course_details_update.
- Bug 3: DictField wrapper models (e.g. GradeCutoffs) have their
to_dict() called unconditionally in parent model's to_dict(), but
users naturally pass plain Python dicts. Fixed with an isinstance
guard: call .to_dict() only when the value is not already a dict.
auth.py: set Accept: application/json as a default header in get_client().
XBlock retrieve returns 406 without it — httpx sends Accept: */* by
default which the view rejects.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…groups
Covers all five API groups exposed by the SDK with working, copy-paste
ready code snippets:
- Home v3: retrieve (studio name + courses + libraries), courses-only,
libraries-only endpoints
- Home v4: paginated courses with count / num_pages / results traversal
- Course Details v3: retrieve and PUT round-trip (retrieve → mutate →
update → restore pattern)
- Authoring Grading v3: PATCH with typed grade_cutoffs, grace_period,
and minimum_grade_credit fields (no more additional_properties hack)
- XBlock v1: retrieve, create, partial_update (rename), destroy —
including a single end-to-end lifecycle example
Also updates README to:
- Use typed SDK calls (v3_home_retrieve, v4_home_courses_retrieve) in
the Authentication, Usage, and Testing Locally sections instead of
the raw client.get_httpx_client().request() call
- Add a link to docs/testing-sdk-apis.rst from the Testing Locally
section for readers who want the full per-API examples
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extends the SDK to cover the LMS Enrollment v2 API by merging an LMS drf-spectacular schema into the Studio schema during regen_sdk.sh. SDK changes: - regen_sdk.sh: download LMS schema from /lms-api/schema/, pass --merge to filter_schema.py; add Bug 5 fix (plain-list response for enrollment_allowed) - filter_schema.py: add merge_schema(), fix_path_parameters() to strip spurious path params that cause the generator to skip endpoints; add --merge CLI flag - New API modules: v2_enrollment_*, v2_course_retrieve, v2_roles_retrieve, v2_enrollments_list (11 files) - New models: CourseEnrollment, EnrollmentCourse, CourseEnrollmentAllowed, and supporting paginated/response models (13 files) - lms_schema.yml: cached LMS enrollment schema Bug fixes applied at regen time: - Bug 4: null-safe datetime parsing in EnrollmentCourse.from_dict() - Bug 5: plain-list normalisation in PaginatedCourseEnrollmentAllowedList Docs: - README.md: add Enrollment v2 to covered APIs table, update regen steps - docs/testing-sdk-apis.rst: update enrollment section with correct module names, base URL (/api/enrollment), and accurate LMS schema note Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Jul 6, 2026
feanil
self-requested a review
July 29, 2026 14:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
regen_sdk.shthat downloads the schema.yml from locally running instancehttp://studio.local.openedx.io:8001/authoring-api/schema/and the LMS enrollment schema fromhttp://local.openedx.io:8000/lms-api/schema/(Link).filter_schema.pyscript, ourregen_sdk.shscript filters out our tagged APIs from both schemas, merges them into a single filtered schema.openapi-python-clientand filtered schema, ourregen_sdk.shscript regenerates the sdk.