Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add image upload field in django rest swagger

I am using Django rest swagger. Added a image filed to serializer which appears in rest framework UI. But do not appear in Swagger UI.

Added the following field in serializer. upload_photo = serializers.ImageField( required=False)

But swagger showing a simple text field. While rest framework showing a upload field. Can anyone help me to show upload field in swagger ui as well

like image 243
Muneeb Avatar asked Aug 29 '14 09:08

Muneeb


1 Answers

For a file field you can override th YAML doctstring for the field:

parameters:
    -
      name: file
      type: file
like image 161
Dseed Avatar answered Sep 21 '22 12:09

Dseed