[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Swagger 2.0 spec allows array of files #550

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ziaenezhad
Copy link

so in this form, maxCount is not necessary https://swagger.io/docs/specification/2-0/file-upload/

@googlebot
Copy link

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. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@uniquejava
Copy link
uniquejava commented Dec 10, 2018

@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 swagger.yaml as following (the swagger OpenAPI2.0 documentation used this as one example),

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.

@uniquejava
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants