I am currently doing multiple files upload using swagger operation. Following are the codes that I am working with:
class uploadImage(Resource):
@swagger.operation(
notes='Upload an image file',
parameters=[
{
"name": "file[]",
"description": "Upload an image file. File size limit is 3MB. Only '.jpg' is allowed ",
"required": True,
"allowMultiple": True,
"dataType": 'file',
"paramType": "form"
}
])
def post(self):
files=request.files.getlist['file[]']
filenames = []
for file in files:
filename = secure_filename(file.filename)
filenames.append(filename)
print "Files are uploaded successfully"
Although I inserted "allowMultiple":True in the code, but it did not show in the swagger UI. Once the server is up, I try to view the html source code, "multiple" does not display in the form.
Following is the source code for swagger ui when the server is up:
<input class="parameter" type="file" name="file[]">
The word "multiple" is missing from the .
If I edit the source code and add in the word "multiple" as below, I manage to select multiple files.
<input class="parameter" type="file" name="file[]" multiple>
It seems like "allowMultiple":True does not work for me in this case.
Any idea or suggestion for me?
Thank you.
That's just not supported by Swagger. See https://github.com/swagger-api/swagger-spec/issues/254.