-
Notifications
You must be signed in to change notification settings - Fork 260
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
Function similar to COMPONENT_SPLIT_REQUEST but for responses? #912
Comments
Ok, so this is completely unrelated to This is basically a duplicate of #375 (comment) The expectation is that serializers don't change their form under the same class (name). We have not attempted to solve this as there is no optimal solution. You can however fix this with a OpenApiSerializerExtension Add another arg for |
Also add ``ref_name`` argument to mitigate the naming collision of parametrized serializers. https://www.django-rest-framework.org/api-guide/serializers/#dynamically-modifying-fields
since this has been asked before and writing that extension is non-trivial, I added a test/example. please refer to this commit on how to solve the issue. |
Thanks for the help! |
I have tried to find out if there is a way to generate a different component for each response from my endpoints, since I have implemented the dynamic fields of the serializers (https://www.django-rest-framework.org/api-guide/serializers/#example). My problem occurs when a serializer is reused and the component always gives the same response, but it must change based on the fields to be used in the serializer.
My
PermissionSerializer
uses theRoleSerializer
and should display theid
andname
fields as shown in the image and there are no problems with this.Instead my main endpoint for my
RoleSerializer
should display all the fields but it doesn't because it should be using the record stored by theRoleSerializer
.Removing the
PermissionSerializer
endpoint documentation found theRoleSerializer
documentation correct.It should be noted that the serializer used by
PermissionSerializer
is the same asRoleSerializer
, only that the fields are filtered through the fields attribute as shown in the link provided above.I hope to explain my question and problem in detail
The text was updated successfully, but these errors were encountered: