drf-yasg icon indicating copy to clipboard operation
drf-yasg copied to clipboard

Nested serializer in MultiPart form parser

Open MatejMijoski opened this issue 3 years ago • 4 comments

Bug Report

Description

I am getting a drf_yasg.errors.SwaggerGenerationError: cannot instantiate nested serializer as Parameter when using nested serializers with multi part form parser.

Stack trace / Error message

  File "C:\Users\PC\Desktop\api\.venv\lib\site-packages\drf_yasg\inspectors\base.py", line 110, in probe_inspectors
    result = method(obj, **kwargs)
  File "C:\Users\PC\Desktop\api\.venv\lib\site-packages\drf_yasg\inspectors\field.py", line 86, in field_to_swagger_object
    raise SwaggerGenerationError("cannot instantiate nested serializer as " + swagger_object_type.__name__)
drf_yasg.errors.SwaggerGenerationError: cannot instantiate nested serializer as Parameter
HTTP GET /?format=openapi 500 [3.81, 127.0.0.1:51926]

I've tried to solve this by using a serializer inspector and with that, changing the nested serializer as a dictionary of fields but that doesn't seem to work. Is there a workaround for this?

MatejMijoski avatar Feb 14 '22 17:02 MatejMijoski

Any fix?

nomidaepapi avatar Jun 15 '22 10:06 nomidaepapi

@nomidaepapi no not yet, as far as I am aware.

creyD avatar Jul 18 '22 15:07 creyD

I also got the same issue while using the drf-writable-nested package.

mgrsantox avatar Aug 02 '22 15:08 mgrsantox

Still no fix? unfortunately had to remove both form parser and multipart parse from my function definition which means the swagger docs can't take files for those endpoints in the documentation

codemunsta avatar Feb 11 '24 18:02 codemunsta