rsinger86 / drf-flex-fields

Dynamically set fields and expand nested resources in Django REST Framework serializers.
MIT License
736 stars 61 forks source link

Improve documentation generation #99

Closed Rjevski closed 2 years ago

Rjevski commented 2 years ago

This PR fixes an exception when generating docs when using the filter backend:

File "/Users/andre/.pyenv/versions/[...]/lib/python3.9/site-packages/rest_flex_fields/filter_backends.py", line 154, in get_schema_operation_parameters
    expandable_fields = self._get_expandable_fields(serializer_class)
TypeError: _get_expandable_fields() missing 1 required keyword-only argument: 'serializer_class'

In addition, it improves the documentation generation by using the REST_FLEX_FIELDS settings values for field names (instead of hardcoding to fields/expand/omit) and populates examples for those fields with fields lists inferred from the serializer + wildcard values for the "all" option.