mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Fix for issue #2036, python client wont upload list of files
This commit is contained in:
parent
4a8927f0e3
commit
5ac630f7ff
@ -1366,6 +1366,8 @@ public class DefaultCodegen {
|
||||
} else if (param instanceof FormParameter) {
|
||||
if ("file".equalsIgnoreCase(((FormParameter) param).getType())) {
|
||||
p.isFile = true;
|
||||
} else if("file".equals(p.baseType)){
|
||||
p.isFile = true;
|
||||
} else {
|
||||
p.notFile = true;
|
||||
}
|
||||
|
@ -395,13 +395,14 @@ class ApiClient(object):
|
||||
for k, v in iteritems(files):
|
||||
if not v:
|
||||
continue
|
||||
|
||||
with open(v, 'rb') as f:
|
||||
filename = os.path.basename(f.name)
|
||||
filedata = f.read()
|
||||
mimetype = mimetypes.\
|
||||
guess_type(filename)[0] or 'application/octet-stream'
|
||||
params[k] = tuple([filename, filedata, mimetype])
|
||||
all_files = v if type(v) is list else [v]
|
||||
for n in all_files:
|
||||
with open(n, 'rb') as f:
|
||||
filename = os.path.basename(f.name)
|
||||
filedata = f.read()
|
||||
mimetype = mimetypes.\
|
||||
guess_type(filename)[0] or 'application/octet-stream'
|
||||
params[k] = tuple([filename, filedata, mimetype])
|
||||
|
||||
return params
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user