rsinger86 / drf-flex-fields

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

_get_expandable_fields() returns a list but is used by get_schema_fields() to concatenate str #116

Closed erielias closed 1 year ago

erielias commented 1 year ago

The filter_backends.py.FlexFieldsDocsFilterBackend.get_schema_fields() tries to concatenate the result of the _get_expandable_fields() as a string but the later returns a list. Therefore this results in a error:

File "/Users/erielias/miniconda3/envs/sr/lib/python3.8/site-packages/rest_flex_fields/filter_backends.py", line 109, in get_schema_fields example=(expandable_fields or "field1,field2,nested.field") + "," + WILDCARD_VALUES_JOINED, TypeError: can only concatenate list (not "str") to list

A possible fix that worked for me was simply replacing: example=(expandable_fields or "field1,field2,nested.field") + "," + WILDCARD_VALUES_JOINED, by example=(",".join(expandable_fields) or "field1,field2,nested.field") + "," + WILDCARD_VALUES_JOINED,

Please let me know if that makes sense so I can create a Pull Request.

Thanks