django-rest-swagger
django-rest-swagger copied to clipboard
Nested serialization shown as string in Swagger UI
I am currently on 2.1.2 and experiencing an issue very much alike https://github.com/marcgibbons/django-rest-swagger/issues/568 and https://github.com/marcgibbons/django-rest-swagger/issues/663.
# serializers.py
class NestedObjectSerializer(serializers.Serializer):
key = serializers.CharField(
max_length=200,
)
value = serializers.DecimalField(
max_digits=3,
decimal_places=2,
)
class RequestSerializer(serializers.Serializer):
dictionary = serializers.DictField()
nested_object = NestedObjectSerializer(
many=True,
)
# views.py
class SomeView(GenericAPIView):
permission_classes = []
serializer_class = RequestSerializer
def post(self, request):
request_serializer = RequestSerializer(data=request.data)
request_serializer.is_valid(raise_exception=True)
...
return Response(response_serializer.data)
Although I am using a DictField in the Request Serializer, Swagger UI shows the data type of the field as string
in both the Model & Example Value:
# Swagger UI
{ |
"dictionary": "string", | inline_model {
"nested_object": [ | lead_profile (string): ,
"string" | data_point_requests (Array[string]):
] | }
} |
Same applies for the nested serialized object.
I am thankful for any hints!
Today I digged a little deeper into this and found out that both OpenAPI Codec and CoreJSON Codec do not support this although schemas are generated correctly by SchemaGenerator, so I assume this is not an issue that can be resolved within the scope of this project.
I experience the same Problem. @korbinianfritsch this might seam out of scope but none the less it should be fixed somehow, because projects need the depiction of cross table relations in the docs.
+1
Since this project seems dead I made an attempt at rolling my own to solve this and other problems I encountered... see here https://github.com/axnsan12/drf-yasg/ 😄
Is there any updates regarding this issue?
any update on this ?