Skip to content

fix: give CourseEnrollmentsApiListSerializer its own schema ref_name - #39192

Merged
Faraz32123 merged 1 commit into
masterfrom
fix/enrollment-serializer-ref-name
Oct 7, 2026
Merged

Faraz32123 merged 1 commit into
masterfrom
fix/enrollment-serializer-ref-name

Conversation

@Faraz32123

@Faraz32123 Faraz32123 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes wrong API documentation for the enrollment create/retrieve endpoints. The API itself already works correctly; only the OpenAPI schema (and clients generated from it) change.

CourseEnrollmentsApiListSerializer declares class Meta(CourseEnrollmentSerializer.Meta), so it inherits the parent's ref_name = "CourseEnrollment". Both serializers were published under one OpenAPI component.

In the full /api-docs schema, which docs/lms-openapi.yaml is generated from since #39108, the cut-down serializer won that collision. As a result:

  • POST /api/enrollment/v2/enrollment/ and GET /api/enrollment/v2/enrollment/{course_id} (and {username},{course_id}) were documented as returning course_id instead of course_details.
  • Clients generated from the schema, such as openedx-platform-sdk, were typed accordingly.

This gives the subclass its own ref_name, CourseEnrollmentsApiList. That is the component name it was published under before the collision surfaced.

No runtime behaviour changes: ref_name is read only by schema generation.

Testing

  • Generated the full LMS schema the same way generate_openapi_schemas.yml does (docs.docs_settings):
    • CourseEnrollment has course_details, created, is_active, mode, user, and is referenced by enrollment create and retrieve.
    • CourseEnrollmentsApiList has course_id, created, is_active, mode, user, and is referenced only by GET /api/enrollment/v2/enrollments/.
  • pytest openedx/core/djangoapps/enrollments/: 272 passed.

The committed docs/lms-openapi.yaml picks this up on the next run of the schema workflow.

CourseEnrollmentsApiListSerializer's Meta subclasses its parent's, so it
inherited ref_name = "CourseEnrollment". Both serializers were published
under one schema component, and in the full /api-docs schema the subset
serializer won: the enrollment create and retrieve endpoints were documented
with course_id instead of course_details, and clients generated from the
schema were typed accordingly.
@Faraz32123
Faraz32123 merged commit 59a94d1 into master Oct 7, 2026
46 checks passed
@Faraz32123
Faraz32123 deleted the fix/enrollment-serializer-ref-name branch October 7, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants