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

api/swagger/?format=openapi response 500

Open dpreal opened this issue 3 years ago • 2 comments

image

dpreal avatar Jun 04 '21 09:06 dpreal

SwaggerGenerationError at /api/swagger/

Schema for <class 'rest_framework_mongoengine.serializers.DocumentSerializer.build_nested_embedded_field.<locals>.EmbeddedSerializer'> would override distinct serializer <class 'rest_framework_mongoengine.serializers.DocumentSerializer.build_nested_embedded_field.<locals>.EmbeddedSerializer'> because they implicitly share the same ref_name; explicitly set the ref_name attribute on both serializers' Meta classes
Request Method: | GET -- | -- http://localhost:8000/api/swagger/?format=openapi 3.1 SwaggerGenerationError Schema for <class 'rest_framework_mongoengine.serializers.DocumentSerializer.build_nested_embedded_field.<locals>.EmbeddedSerializer'> would override distinct serializer <class 'rest_framework_mongoengine.serializers.DocumentSerializer.build_nested_embedded_field.<locals>.EmbeddedSerializer'> because they implicitly share the same ref_name; explicitly set the ref_name attribute on both serializers' Meta classes /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/drf_yasg/inspectors/field.py, line 135, in field_to_swagger_object /usr/local/bin/python3 3.7.9 ['/Users/dp/idp/kscloud/code/TeamVision/teamvision_1.0_dev/teamvision', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/dp/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages'] Fri, 04 Jun 2021 17:18:29 +0800

dpreal avatar Jun 04 '21 09:06 dpreal

Hello, you can't have 2 serializers with the same name, the error message explains what you can do to fix the issue.

etene avatar Jun 25 '21 08:06 etene