rsinger86/drf-flex-fields

Swagger does not work when add FlexFieldsFilterBackend in my view

Labaffe opened this issue · 0 comments

When i load my Swagger, it failed.

Exception raised in "get_schema_fields".

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

Indeed, expandable_fields is a list of string and you cant concat ",".

If I apply a join, it works but I dont know if it will break something.

coreapi.Field(
    name=EXPAND_PARAM,
    required=False,
    location="query",
    schema=coreschema.String(
        title="Expanded fields",
        description="Specify expanded fields by comma",
    ),
    example=(','.join(expandable_fields) or "field1,field2,nested.field") + "," + WILDCARD_VALUES_JOINED,
),

Best regards.