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.
我正在使用Django休息招摇。添加了一个映射到序列化程序的图像,该图像显示在rest框架UI中但是不要出现在Swagger UI中。
Added the following field in serializer. upload_photo = serializers.ImageField( required=False)
在序列化程序中添加了以下字段。 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
但招摇过来显示一个简单的文本字段。休息框架显示上传字段。任何人都可以帮助我在swagger ui中显示上传字段
2 个解决方案
#1
1
For a file field you can override th YAML doctstring for the field:
对于文件字段,您可以覆盖该字段的YAML doctstring:
parameters:
-
name: file
type: file
#2
0
Why not use the image url instead works way better, the ImageField gave me endless issues as well you can call the image by upload_photo.url returns the same value as upload_photo in normal text
为什么不使用图片网址更好地工作,ImageField给了我无穷无尽的问题,你可以通过upload_photo.url调用图像返回与普通文本中的upload_photo相同的值
#1
1
For a file field you can override th YAML doctstring for the field:
对于文件字段,您可以覆盖该字段的YAML doctstring:
parameters:
-
name: file
type: file
#2
0
Why not use the image url instead works way better, the ImageField gave me endless issues as well you can call the image by upload_photo.url returns the same value as upload_photo in normal text
为什么不使用图片网址更好地工作,ImageField给了我无穷无尽的问题,你可以通过upload_photo.url调用图像返回与普通文本中的upload_photo相同的值