New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable multiple file support? #254

Open
fehguy opened this Issue Jan 28, 2015 · 15 comments

Comments

Projects
None yet
@fehguy
Contributor

fehguy commented Jan 28, 2015

While not explicitly allowed, it seems we might want to enable type: file inside arrays to allow for support of multiple files.

@James-Messinger

This comment has been minimized.

Show comment
Hide comment
@James-Messinger

James-Messinger Jan 29, 2015

Contributor

Can't you already accomplish this by simply having more than one parameter with {type: "file"}? As long as your Content-Type is multipart/form-data, you can send multiple files in a single request.

Or am I missing something?

Contributor

James-Messinger commented Jan 29, 2015

Can't you already accomplish this by simply having more than one parameter with {type: "file"}? As long as your Content-Type is multipart/form-data, you can send multiple files in a single request.

Or am I missing something?

@webron

This comment has been minimized.

Show comment
Hide comment
@webron

webron Jan 30, 2015

Member

@BigstickCarpet - the idea is to allow an undefined number of files to upload. You can set several individual parameters but that's not quite the same.

Member

webron commented Jan 30, 2015

@BigstickCarpet - the idea is to allow an undefined number of files to upload. You can set several individual parameters but that's not quite the same.

@James-Messinger

This comment has been minimized.

Show comment
Hide comment
@James-Messinger

James-Messinger Jan 30, 2015

Contributor

Ah, ok. 👍

Contributor

James-Messinger commented Jan 30, 2015

Ah, ok. 👍

@bytesandwich

This comment has been minimized.

Show comment
Hide comment
@bytesandwich

bytesandwich May 8, 2015

Any thoughts on this? multiple file upload (where the user decides how many files to upload) seems like a really common use case.
Enough that dropzone has nearly 8,000 stars https://github.com/enyo/dropzone

bytesandwich commented May 8, 2015

Any thoughts on this? multiple file upload (where the user decides how many files to upload) seems like a really common use case.
Enough that dropzone has nearly 8,000 stars https://github.com/enyo/dropzone

@webron

This comment has been minimized.

Show comment
Hide comment
@webron

webron Jul 31, 2015

Member

So following #50, we may be able to allow the declaration of an array of "type": "string", "format": "binary" as a workaround for multiple file upload definitions.

Member

webron commented Jul 31, 2015

So following #50, we may be able to allow the declaration of an array of "type": "string", "format": "binary" as a workaround for multiple file upload definitions.

@Hronom

This comment has been minimized.

Show comment
Hide comment
@Hronom

Hronom Oct 29, 2016

Any progress on this?

Hronom commented Oct 29, 2016

Any progress on this?

@fehguy

This comment has been minimized.

Show comment
Hide comment
@fehguy

fehguy Oct 29, 2016

Contributor

Most likely part of 3.0

Contributor

fehguy commented Oct 29, 2016

Most likely part of 3.0

@akkie

This comment has been minimized.

Show comment
Hide comment
@akkie

akkie Feb 17, 2017

Currently this should be possible with:

- name: files
  in: formData
  description: Upload multiple files
  required: true
  type: array
  items:
    type: File
  collectionFormat: multi

If the documentation could be adapted to:

corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in "query" or "formData". For files in "formData" an numeric index will be appended to the parameter name (files0, files1, ...).

akkie commented Feb 17, 2017

Currently this should be possible with:

- name: files
  in: formData
  description: Upload multiple files
  required: true
  type: array
  items:
    type: File
  collectionFormat: multi

If the documentation could be adapted to:

corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in "query" or "formData". For files in "formData" an numeric index will be appended to the parameter name (files0, files1, ...).

akkie pushed a commit to akkie/swagger-codegen-play-scala that referenced this issue Feb 17, 2017

Christian Kaps
Support for a list of files in a multipart/form-data request
Please note that this is currently not specified and it may be the case that this changes in a future version of the specification.

An upload can be handled with the following definition:
- name: files
   in: formData
   description: Upload multiple files
   required: true
   type: array
   items:
     type: File
   collectionFormat: multi

   Relates to: OAI/OpenAPI-Specification#254

akkie added a commit to mohiva/swagger-codegen-play-scala that referenced this issue Feb 17, 2017

Support for a list of files in a multipart/form-data request (#2)
Please note that this is currently not specified and it may be the case that this changes in a future version of the specification.

An upload can be handled with the following definition:
- name: files
  in: formData
  description: Upload multiple files
  required: true
  type: array
  items:
    type: File
  collectionFormat: multi

Relates to: OAI/OpenAPI-Specification#254
@darrelmiller

This comment has been minimized.

Show comment
Hide comment
@darrelmiller

darrelmiller Feb 17, 2017

Member

A new approach has been introduced in the V3 spec to model multi-part forms included files. The type: file has been removed because it is not valid in JSON Schema. Also, request bodies are no longer modeled as parameters.

Member

darrelmiller commented Feb 17, 2017

A new approach has been introduced in the V3 spec to model multi-part forms included files. The type: file has been removed because it is not valid in JSON Schema. Also, request bodies are no longer modeled as parameters.

@ePaul

This comment has been minimized.

Show comment
Hide comment
@ePaul

ePaul Mar 19, 2017

Contributor

@darrelmiller Are you meaning to say that uploading e.g. an array of files is now possible?

I guess the explode property of encoding can help here, thought I'm not sure this is the correct way of doing this:

requestBody:
  content:
    multipart/mixed:
      schema:
        type: object
        properties:
          id:
            # default is text/plain
            type: string
            format: uuid
          address:
            # default is application/json
            type: object
            properties: {}
          profileImages:
            # default is application/octet-stream, need to declare an image type only!
            type:array
            items:
              type: string
              format: binary
      encoding:
        profileImages:
          # only accept png/jpeg
          contentType: image/png, image/jpeg
          style: form
          explode: true

How would the form images be named in the request? profileImages[0], profileImages[1], ...?
I guess this needs some clarification (and an example) in the spec.

Contributor

ePaul commented Mar 19, 2017

@darrelmiller Are you meaning to say that uploading e.g. an array of files is now possible?

I guess the explode property of encoding can help here, thought I'm not sure this is the correct way of doing this:

requestBody:
  content:
    multipart/mixed:
      schema:
        type: object
        properties:
          id:
            # default is text/plain
            type: string
            format: uuid
          address:
            # default is application/json
            type: object
            properties: {}
          profileImages:
            # default is application/octet-stream, need to declare an image type only!
            type:array
            items:
              type: string
              format: binary
      encoding:
        profileImages:
          # only accept png/jpeg
          contentType: image/png, image/jpeg
          style: form
          explode: true

How would the form images be named in the request? profileImages[0], profileImages[1], ...?
I guess this needs some clarification (and an example) in the spec.

@darrelmiller

This comment has been minimized.

Show comment
Hide comment
@darrelmiller

darrelmiller Mar 19, 2017

Member

I know we discussed this scenario and it was intended to support it. I don't believe style needs to be used here because style is a serialization hint and binary streams of images are not going to be encoded with key value pairs. As for how the naming of the parts is defined, I'm not sure, but your suggestion does make sense.

We got to a point with the definition of the multi-part stuff where we felt we needed to actually try implementing some of the scenarios before we rat-holed on trying to get the definition airtight.

Member

darrelmiller commented Mar 19, 2017

I know we discussed this scenario and it was intended to support it. I don't believe style needs to be used here because style is a serialization hint and binary streams of images are not going to be encoded with key value pairs. As for how the naming of the parts is defined, I'm not sure, but your suggestion does make sense.

We got to a point with the definition of the multi-part stuff where we felt we needed to actually try implementing some of the scenarios before we rat-holed on trying to get the definition airtight.

@webron

This comment has been minimized.

Show comment
Hide comment
@webron

webron Mar 19, 2017

Member

We should have made it clearer in the spec - iirc, style and explode are both only relevant when the media type is application/x-www-form-urlencoded.

As for the naming, what @darrelmiller said.

Member

webron commented Mar 19, 2017

We should have made it clearer in the spec - iirc, style and explode are both only relevant when the media type is application/x-www-form-urlencoded.

As for the naming, what @darrelmiller said.

@tuxedo0801

This comment has been minimized.

Show comment
Hide comment
@tuxedo0801

tuxedo0801 Jul 24, 2018

Any progress on this? Open since ~3yrs and counting ...

tuxedo0801 commented Jul 24, 2018

Any progress on this? Open since ~3yrs and counting ...

@vdachev

This comment has been minimized.

Show comment
Hide comment
@vdachev

vdachev Aug 11, 2018

@tuxedo0801 , actually OpenAPI 3.0 supports defining multi-file upload.

vdachev commented Aug 11, 2018

@tuxedo0801 , actually OpenAPI 3.0 supports defining multi-file upload.

@immondu

This comment has been minimized.

Show comment
Hide comment

immondu commented Aug 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment