mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 18:09:59 +03:00
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:
parent
9d06e43d05
commit
8e3594364f
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user