I am trying to make upload file input from swagger (with drf-yasg
), but when I use MultiPartParser
class it gives me the below error:
drf_yasg.errors.SwaggerGenerationError: FileField is supported only in a formData Parameter or response Schema
My view:
class AddExperience(generics.CreateAPIView):
parser_classes = [MultiPartParser]
permission_classes = [IsAuthenticated]
serializer_class = DoctorExperienceSerializer
My serializer:
class DoctorExperienceSerializer(serializers.Serializer):
diploma = serializers.ListField(
child=serializers.FileField(allow_empty_file=False)
)
education = serializers.CharField(max_length=1000)
work_experience = serializers.CharField(max_length=1000)
I also tried FormParser
but it still gives me the same error. Also: FileUploadParser
parser but it works like JsonParser
: