Introspect ManyRelatedField data type recursively

For all `ManyRelatedField` objects, we were assuming that the inner type was always a `String`. While this may be true for the default output, a `ManyRelatedField` is a wrapper for a lot of other classes which includes more than just strings. This should allow us to document lists of things other than strings.
This commit is contained in:
Kevin Brown 2019-03-05 19:58:22 -05:00
parent 9d06e43d05
commit 8e3594364f

View File

@ -51,8 +51,10 @@ def field_to_schema(field):
description=description description=description
) )
elif isinstance(field, serializers.ManyRelatedField): elif isinstance(field, serializers.ManyRelatedField):
related_field_schema = field_to_schema(field.child_relation)
return coreschema.Array( return coreschema.Array(
items=coreschema.String(), items=related_field_schema,
title=title, title=title,
description=description description=description
) )