-
Notifications
You must be signed in to change notification settings - Fork 373
Swagger 2.0 spec allows array of files #550
base: master
Are you sure you want to change the base?
Conversation
so in this form, maxCount is not necessary https://swagger.io/docs/specification/2-0/file-upload/
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
@whitlockjc Hello, any chance this will be merged, I think upload multiple files is a common use case. I need to upload multiple files. I specified API definition in in app.js let upload = multer({
storage: multer.memoryStorage(),
limits: {
fileSize: 5 * 1024 * 1024
}
});
app.use(upload.fields([{ name: "myfile" }]));
// install middleware
swaggerExpress.register(app); in swagger.yml consumes:
- multipart/form-data
parameters:
- name: client_id
in: query
description: client id
type: string
required: true
- name: some_field1
in: formData
type: string
required: true
- name: some_fieild2
in: formData
type: string
required: true
- name: some_field3
in: formData
type: string
required: true
- name: myfile
in: formData
type: array
items:
type: string
format: binary
required: true This pull request fixed my problem. before that, It will always return this error. {"message":"Validation errors",
"errors":[
{
"code":"INVALID_REQUEST_PARAMETER",
"errors":[{"code":"REQUIRED","message":"Value is required but was not provided","path":["paths","/user","post","parameters","4"]}],
"in":"formData",
"message":"Invalid parameter (myfile): Value is required but was not provided",
"name":"myfile",
"path":["paths","/user","post","parameters","4"]
}
]
} Using the code from this PR., the upload request performed successfully. |
Fixed. 😄 the above issues resolved with the following configuration(without this PR) - name: myfile
in: formData
type: file
items:
type: string
format: binary
required: true |
so in this form, maxCount is not necessary https://swagger.io/docs/specification/2-0/file-upload/