-
Notifications
You must be signed in to change notification settings - Fork 248
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
https://www.django-rest-framework.org/api-guide/serializers/#dynamically-modifying-fields #1235
Comments
here i explained the problem too |
i found a solution, i don't like it but works @extend_schema(
i tried to add in preprocessor or postprosessor hooks but w/o any real good solution |
Hi, this was discussed before in #375 please see this: #375 (comment) and #375 (comment) for a solution. You basically need an fyi: for placing the extension: https://drf-spectacular.readthedocs.io/en/latest/customization.html#step-5-extensions |
Describe the bug
With DynamicFieldsModelSerializer from django rest framework swagger dosen't produce the full schema of object
https://www.django-rest-framework.org/api-guide/serializers/#dynamically-modifying-fields
To Reproduce
take two models with some different fields and their serializers
class ItemCategorySerializer(DynamicFieldsModelSerializer ):
class Meta:
model = ItemCategory
fields = "all"
class ItemSerializer(DynamicFieldsModelSerializer):
class Meta:
model = Item
fields = "all"
I want show only fews details for ItemCategory when is inside Item so i added DynamicFieldsModelSerializer and on category_obj fields=['id', 'name', ]
when i generate full schema model of ItemCategory lose all fields except id and name, instead if i remove fields=['id', 'name', ]
the autogenerated schema will have all fields,
that is a problem because when i make my view with ItemCategory i want all fields, seems autogenerated
ItemCategorySerializer( fields=['id', 'name', ])
replace ItemCategorySerializer() called before
Expected behavior
i Expect to have all fields in my ItemCategory schema w/o create a new serializer
The text was updated successfully, but these errors were encountered: