feathersjs-ecosystem / feathers-swagger

Add documentation to your FeatherJS services and feed them to Swagger UI.
MIT License
225 stars 63 forks source link

Multi file upload not working #200

Closed dangxquang closed 4 years ago

dangxquang commented 4 years ago

I defined a route with multipart/form-data file upload.

uploads.docs = {
    description: 'A service to upload files',
    externalDocs: {
      description: 'Swaggers',
      url: 'https://github.com/feathersjs-ecosystem/feathers-swagger',
    },
    model: 'Uploads',
    tag: 'Uploads',
    operations: {
      find: false,
      get: false,
      update: false,
      remove: false,
      patch: false,
      create: {
        description: 'Upload files',
        requestBody: {
          content: {
            'multipart/form-data': {
              schema: {
                type: 'object',
                properties: {
                  files: {
                    type: 'array',
                    items: {
                      type: 'string',
                      format: 'binary'
                    }
                  }
                },
              },
            },
          },
        },
      },
    },
  }

But the form-data is not correct with CURL: curl -X POST "http://localhost:3030/v1/uploads" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "file=[object File]" image

Does anyone success with multiple files upload? Sorry for my poor english

Mairu commented 4 years ago

Hi, I have not worked with file uploads yet. But this "problem" is only related to swagger-ui and swagger specification.

Your definition looks correct.

As by default an old version of swagger-ui is used, you should try to use swagger-ui as a direct dependency of your project, to use the current version. If the problem still occurs, you should ask the swagger-ui people.