Skip to content
New issue

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

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

Already on GitHub? # to your account

collectionFormat: multi on multipart/form-data discards all values except the last one #207

Open
Hurricaaane opened this issue Sep 21, 2017 · 0 comments

Comments

@Hurricaaane
Copy link

Hurricaaane commented Sep 21, 2017

Assume there is a route expecting an array parameter in the body of a multipart/form-data request with collectionFormat: "multi"

Currently in the master branch, when multiple parts are passed which names match that parameter, only a single value is present in the List passed to the controller of that route.

This is probably caused by the method which stores the different parts into a Map: https://github.com/swagger-api/swagger-inflector/blob/master/src/main/java/io/swagger/inflector/controllers/SwaggerOperationController.java#L212


For instance, this spec:

paths:
  /dummy/doNothing:
    post:
      tags:
        - pet
      operationId: doNothing
      consumes:
        - multipart/form-data
      parameters:
        - name: status
          in: formData
          required: false
          type: array
          items:
            type: string
          collectionFormat: multi
      responses:
        "204":
          description: Nothing was done

...with this controller:

    public ResponseContext doNothing(RequestContext rc, List<String> status) {
        System.out.println(status);
        return new ResponseContext().status(Status.NO_CONTENT);
    }

...and this request payload with three values "sleeping", "napping" and "procrastinating" for the status parameter:

------WebKitFormBoundaryzrxpSKPNfesaI3me
Content-Disposition: form-data; name="status"

sleeping
------WebKitFormBoundaryzrxpSKPNfesaI3me
Content-Disposition: form-data; name="status"

napping
------WebKitFormBoundaryzrxpSKPNfesaI3me
Content-Disposition: form-data; name="status"

procrastinating
------WebKitFormBoundaryzrxpSKPNfesaI3me--

...results in an ArrayList containing the last value, "procrastinating":

status = {ArrayList@6884}  size = 1
 0 = "procrastinating"
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant