Skip to content
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

[BUG][typescript-axios] 'isCollectionFormatMulti' flag not being set to true on multiple file uploads #8104

Closed
5 of 6 tasks
BrMtssk opened this issue Dec 5, 2020 · 1 comment · Fixed by #8105
Closed
5 of 6 tasks

Comments

@BrMtssk
Copy link
Contributor

BrMtssk commented Dec 5, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I have the exact use case as described on #7247 for uploading multiple files, but apparently the 'isCollectionFormatMulti' is not set to 'true' on those cases and therefore the generator still handle those parameters as strings.

openapi-generator version

Latest master (3de5370)

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: test
  version: "1.0.0"
tags:
  - name: test
    description: test
servers:
  - url: http://localhost:3000
paths:
  /api/upload:
    post:
      tags: []
      operationId: upload files
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                message:
                  type: string
                files:
                  type: array
                  items:
                    type: string
                    format: binary
              required:
                - message
      responses:
        200:
          description: ok
Generation Details

openapi-generator-cli.jar generate -i foo.yaml -g typescript-axios -o foo

Steps to reproduce

Generate the client via the above command. Verify that the output contains the following lines:

if (files) {
    localVarFormParams.append(files.join(COLLECTION_FORMATS.csv));
}

The desired output should be

if (files) {
    files.forEach((element) => {
        localVarFormParams.append('files', element as any);
    })
}
Related issues/PRs

#7247 #7814

Suggest a fix

Correctly set the flag to true on postProcessParameter. I am going to submit a PR addressing it.

@auto-labeler
Copy link

auto-labeler bot commented Dec 5, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

BrMtssk pushed a commit to BrMtssk/openapi-generator that referenced this issue Dec 5, 2020
macjohnny pushed a commit that referenced this issue Dec 7, 2020
…n multiple file uploads (#8105)

* [typescript-axios] Sets 'isCollectionFormatMulti' to true on file uploads.

Fixes #8104

* Safely checks if dateFormat is "binary" #8105

Co-authored-by: Bruno Matissek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant