Open maltem-za opened 8 years ago
It's because the OpenAPI Renderer
is using CoreAPI Renderer
to supply Swagger
with schema.
The problem is, CoreAPI
does not support nested fields definition. I can not find any info about defining custom types either.
However, DRF already provides a full schema as metadata. http://www.django-rest-framework.org/api-guide/metadata/
It seem to also be used internally for the Browseable API.
The way OpenAPI
is generated should use metadata instead relying on the CoreAPI
I guess.
Model being serialized (simplified):
Serializer definition:
print repr(serializer):
As you can see there are 2 NestedSerializers here, one for the Organisation model and one for the Category model. The endpoint is an APIView that declares the response_serializer explicitly in the YAML docstring.
The problem (see attached screenshot) is that only one of the NestedSerializer definitions is shown. In this case the one for Category. I have also seen the one for Organisation show up, in which case the one for Category is missing.