fix: make page a nullable property and specs updated#3426
fix: make page a nullable property and specs updated#3426marslanabdulrauf wants to merge 2 commits intomainfrom
Conversation
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
7746b42 to
283396f
Compare
fc9abea to
1a2f449
Compare
|
@ChristopherChudzicki should we bump the version for breaking change which is causing |
Sorry I didn't have time to review this more carefully today, but IMO this isn't a breaking change—it's just making the spec accurate. The API can return null now, but the spec doesn't reflect that. We aren't changing the API, we are fixing the spec. |
1a2f449 to
fd56e0e
Compare
|
Oh, I checked the V2Course serializer didn't had Also had similar requirement for Programs as well:
So made changes around that as well and updated the v2 specs. |
👍 That sounds good to me. Again, not a breaking change—the serializer already returned null for page, e.g., https://mitxonline.mit.edu/api/v2/courses/course-v1:UAI_NTUA_SOURCE+NTUA.UAI.VT.3/ (since DRF serializers don't validate responses, only requests). My suggestion is:
|
fd56e0e to
3a37510
Compare
What are the relevant tickets?
https://github.com/mitodl/hq/issues/10652
Description (What does it do?)
This pull request updates the course and program serializers to properly handle cases where a course or program does not have an associated CMS page. The serializers now return
nullfor thepagefield instead of a default object, and the OpenAPI specs are updated to reflect this. Corresponding tests are added to ensure this behavior.Serializer improvements:
CourseSerializerandProgramSerializerto allow thepagefield to benullif there is no associated CMS page, returningNoneinstead of a default object. (courses/serializers/v2/courses.py[1]courses/serializers/v2/programs.py[2]programs.pyby removing unusedget_thumbnail_url. (courses/serializers/v2/programs.pycourses/serializers/v2/programs.pyL15-R15)OpenAPI specification updates:
nullable: trueto thepagefields for courses and programs in all OpenAPI spec versions (v0.yaml,v1.yaml,v2.yaml) to indicate that these fields can benull.Testing:
page: Nonewhen a course or program does not have a CMS page. (courses/serializers/v2/courses_test.py[1]courses/serializers/v2/programs_test.py[2]How can this be tested?