Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #8104
Closed
Open
Issue created Dec 05, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

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

Created by: BrMtssk

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 (closed) 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 (3de53706)

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 (closed) #7814

Suggest a fix

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

Assignee
Assign to
Time tracking