Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django rest swagger nested serializer showing list of array in Example UI

Django Rest Swagger is not able to parse the Inner Serializer as an array of objects instead it shows only list of string

My Serializers:

class InfluencerSerializer(serializers.Serializer):
     prices = PriceSerializer(many=True)
     first_name = serializer.CharField(max_length=100)

class PriceSerializer(serializers.Serializer):
     cost = serializers.IntegerField(default=0)

On Swagger UI it appears as below json in Example

{ 
  "first_name": "string", 
  "prices": ["string"],
}

While I am expected Swagger UI to show { "first_name": "string", "prices": [ {"cost":0} ], }

I am using

Django==1.10.6
djangorestframework==3.6.1
django-rest-swagger==2.1.2
like image 345
Muneeb Avatar asked May 30 '17 07:05

Muneeb


1 Answers

django-rest-swagger does not support nested serializers and lists (ref), use drf-yasg instead

like image 188
Zahra Kabiri Avatar answered Sep 22 '22 07:09

Zahra Kabiri