openapigenerator get_operation multipart workaround causes "cannot instantiate nested serializer as Items" errors
While trying to track down travis build errors for https://github.com/ansible/galaxy_ng/pull/68 (such as https://travis-ci.com/github/ansible/galaxy_ng/builds/164529317), the failure would happen in the api client generation stage when it hits the openapi generator page (ie, pulp/api/v3/docs/) which uses openapigenerator.py.
If nested serializers were used, like https://github.com/ansible/galaxy_ng/pull/68/files#diff-ba7c1556b4ef9c4103fb3c3510d91dbcR29, the api client generator would fail with SwaggerGenerationError errors:
"cannot instantiate nested serializer as Items"
Tracking it down, those errors seemed to be caused by https://github.com/pulp/pulpcore/blob/master/pulpcore/app/openapigenerator.py#L319-L330
This is a workaround to force all operations to be introspected as if they supported multipart bodies.
This causes an odd code path through the various drf_yasg inspectors get_request_body_paramaters() methods.
The get_request_body_paramaters calls the inspectors get_request_paramaters().
When this hits the InlineSerializerInspector.get_request_parameters() it calls probe_field_inspectors() which recursively ends up calling it's field_to_swagger_object().
BUT! get_request_paramaters always calls probe_field_inspects() with a swagger_object_type of openapi.Parameter, so the eventual call to InlineSerializerInspector.field_to_swagger_object() will get called with results of _get_partial_types which ends up being 'Items' if swagger_object_type is not a openapi.Schema.
And InlineSerializerInspector.field_to_swagger_object() in that case always hits line ~94: SwaggerGenerationError("cannot instantiate nested serializer as " + swagger_object_type.name)
I think this could potentially related to other issues with nested serializers some folks mentioned in Slack (ie, needing to make any nested serializers be 'read_only=True' to avoid this error.)