OpenAPITools / OpenAPITools/openapi-generator

[BUG] typescript-axios generator works bad for formdata array

Open
#9,889 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

openapi-generator version

5.1.1

OpenAPI declaration file content or url
 put:
      summary: "Update a new painting"
      operationId: "updatePainting"
      tags:
        - "Paintings"
      consumes:
        - "multipart/form-data"
      parameters:
        - in: "formData"
          name: "image"
          type: "file"
        - in: "formData"
          name: "genres"
          type: **"array"**
          items:
            type: "string"
          required: true
Generation Details

openapi-generator-cli generate -g typescript-axios -i ../server/swagger.yaml -o src/api

Steps to reproduce

Specification example results in:

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

and the error in browser displayed: TypeError: Failed to execute 'append' on 'FormData': 2 arguments required, but only 1 present.

Suggest a fix

Expected result:

if (genres) {
                localVarFormParams.append('genres', genres.join(COLLECTION_FORMATS.csv));
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the typescript-axios generator and reproduce the issue using the provided OpenAPI formData declaration and generation command. Trace the generated FormData handling for the genres array, then verify the generated call includes the parameter name and passes the reproduction without the browser append error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.