-
-
Notifications
You must be signed in to change notification settings - Fork 4
Get the full list of fields on the other methods #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Right now if I set on detail some fields the other are not available in swagger on the put endpoint as example. This fix the issue showing all the fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the get_serializer_class method to ensure that all fields are available in API endpoints for non-read operations (PUT, POST, PATCH, DELETE) in OpenAPI/Swagger documentation, even when detail views have restricted field sets.
- Adds logic to override field restrictions for write operations
- Ensures complete field visibility in Swagger documentation for modification endpoints
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if self.action not in ["list", "detail", "retrieve"]: | ||
| fields_to_use = "__all__" |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic unconditionally overrides fields_to_use for all non-read actions, ignoring the previously calculated field configuration from lines 182-193.
Looking at lines 186-189, the code already handles write operations (create, update, partial_update) by using the detail fields configuration, which is the appropriate behavior. This new code will override that logic and force __all__ fields for these operations.
Additionally, the condition excludes "detail" but not "retrieve", which are typically equivalent actions in DRF. This inconsistency is problematic because:
"retrieve"is the standard DRF action name for getting a single object"detail"is not a standard DRF action name
This will break the existing field configuration logic for models that define different fields for list and detail views (like SampleModel in the tests). For write operations, this might expose fields that should only be visible in detail views, or force all model fields to be serialized when only a subset was intended.
| if self.action not in ["list", "detail", "retrieve"]: | |
| fields_to_use = "__all__" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the point to show all the fields that are defined in turbodrf @copilot
Right now if I set on detail some fields the other are not available in swagger on the put endpoint as example.
This fix the issue showing all the fields.