[AAP-57081] Fix OpenAPI spec for associate/disassociate endpoints#1007
[AAP-57081] Fix OpenAPI spec for associate/disassociate endpoints#1007aap-platform-services-cicd-bot-sa wants to merge 1 commit into
Conversation
…ciate endpoints
The associate and disassociate action methods in AssociateMixin return
HTTP 204 No Content, but the auto-generated OpenAPI spec incorrectly
declared HTTP 200 with a serializer-shaped response body. This was
because drf-spectacular inferred the response from get_serializer_class()
rather than from the actual return value.
Add @extend_schema_if_available(responses={204: None}) decorators to
both methods so the generated spec correctly declares 204 No Content
with no response body.
Includes regression tests that verify the schema declares 204 (not 200)
for all associate/disassociate endpoints.
Assisted-by: Debuggernaut (claude-opus-4-6) <noreply@redhat.com>
|
DVCS PR Check Results: PR appears valid (JIRA key(s) found) |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR introduces OpenAPI schema support for association endpoints by adding 204 No Content response declarations, updates serializer queryset initialization with improved error message handling, and refactors multiple router factory methods for consistency and readability. A new schema regression test validates the 204 response declarations. ChangesOpenAPI Schema Support and Code Improvements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
I don't hate it. |


Summary
The
associate()anddisassociate()methods inAssociateMixinreturnHTTP 204 No Content, but the auto-generated OpenAPI spec incorrectly declaresHTTP 200with a serializer-shaped response body. This is becausedrf-spectacularinfers the response fromget_serializer_class()when no explicit schema annotation is present.This PR adds
@extend_schema_if_available(responses={204: None})decorators to both methods, making the generated OpenAPI spec match the actual API behavior.Changes
ansible_base/lib/routers/association_resource_router.py: Added@extend_schema_if_available(responses={204: None})toassociate()anddisassociate()methodstest_app/tests/lib/routers/test_association_resoure_router.py: Added regression test verifying OpenAPI schema declares204(not200) for associate/disassociate endpointsImpact
200 + bodyto accurate204 No ContentAssociationResourceRouter(gateway, controller, hub, eda) will automatically get correct specsTest Plan
ruff checkpassesruff formatpassestest_associate_disassociate_schema_returns_204validates correct schema generationFixes: AAP-57081
Assisted-by: Debuggernaut (claude-opus-4-6) noreply@redhat.com
Summary by CodeRabbit
Bug Fixes
Tests