Unable to make the ImageField as required in Swagger POST API
See original GitHub issueMy model:
class Image(models.Model):
image=models.ImageField(upload_to='photos')
name=models.CharField(max_length=40,unique=False)
My serializer:
class imagesSerializer(serializers.ModelSerializer):
image = Base64ImageField(required=True)
class Meta:
model = Image
fields = ('id','name','image')
My swagger view:
How to make the imagefield as required in swagger post request ?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:29 (19 by maintainers)
Top Results From Across the Web
drf-yasg: Image field not displaying in swagger ui
I am new to django-rest-framework. I am using DRF and drf-yasg Swagger. Can any body help to upload image from request body? I...
Read more >Unable to make the ImageField as required in Swagger POST API
My model: class Image(models.Model): image=models.ImageField(upload_to='photos') name=models.CharField(max_length=40,unique=False). My serializer:
Read more >Media Types - Swagger
Media type is a format of a request or response body data. Web service operations can accept and return data in different formats,...
Read more >Insightly API v3.1 Help
Review each object's endpoints to understand how to get the data and make changes to the records. For example, to get the links...
Read more >Upload image or file using Django Rest Framework ... - YouTube
How to write REST API for uploading image and file using Django rest framework, How to post file or image from postman to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In Swagger API, I’m using the following setup to show the field as required without any problems:
And to use “string” format instead of an URL, you will need to create the field with use_url=False.
you should change your parser like this :
after that you can check your swagger :
I hope this can help you