Skip to content

[typescript] Align multipart file array handling#24133

Open
hwisu wants to merge 5 commits into
OpenAPITools:masterfrom
hwisu:codex-fix-typescript-fetch-multipart-file-array
Open

[typescript] Align multipart file array handling#24133
hwisu wants to merge 5 commits into
OpenAPITools:masterfrom
hwisu:codex-fix-typescript-fetch-multipart-file-array

Conversation

@hwisu

@hwisu hwisu commented Jun 26, 2026

Copy link
Copy Markdown

Summary

  • Fix multipart file arrays for typescript-fetch, typescript-axios, and typescript-inversify.
  • Treat form params as file arrays when parameter.items is binary.
  • Move the shared check to AbstractTypeScriptClientCodegen.
  • Add regression tests for the generated output.
  • Document the shared binary form-array helper.

Root Cause

For type: array with items: { type: string, format: binary }, the file metadata is on the item schema, not the array schema. These TypeScript generators only checked parameter.dataFormat == "binary", so they could serialize file arrays as csv form values instead of repeated multipart fields.

Cross-Generator Consistency

The same OpenAPI shape is already covered by other generators:

  • modules/openapi-generator/src/test/resources/3_0/form-multipart-binary-array.yaml defines files as an array of binary items.
  • Spring generates List<MultipartFile> files with @RequestPart("files").
  • JAX-RS/Jersey generates List<FormDataBodyPart> files.
  • Java clients add repeated multipart entries with formParams.addAll("files", ...).
  • JavaScript clients pass multipart binary arrays through instead of csv-joining them.
  • Go tests cover array-of-binary operation parameters.

This change applies the same item-level binary check to the affected TypeScript clients.

Regression Safety

  • typescript-axios and typescript-inversify use isCollectionFormatMulti for repeated field serialization.
  • typescript-fetch also needs isFile so multipart requests use FormData.
  • Regenerating the existing typescript-axios echo sample produced no diff.
  • Regenerating the existing typescript-inversify petstore sample produced no diff.
  • Added a focused typescript-fetch sample for this case.

Validation

  • ./mvnw -pl modules/openapi-generator -am -Dtest=TypeScriptFetchClientCodegenTest,TypeScriptAxiosClientCodegenTest,TypeScriptInversifyClientCodegenTest -Dsurefire.failIfNoSpecifiedTests=false test
  • ./bin/generate-samples.sh bin/configs/typescript-fetch-multipart-file-array.yaml
  • ./bin/generate-samples.sh bin/configs/typescript-axios-echo-api.yaml
  • ./bin/generate-samples.sh bin/configs/typescript-inversify.yaml
  • git diff --check upstream/master...HEAD
  • Earlier validation on this branch:
    • ./mvnw -pl modules/openapi-generator-cli -am -DskipTests package
    • ./mvnw clean package
    • ./bin/generate-samples.sh ./bin/configs/*.yaml
    • ./bin/utils/export_docs_generators.sh

Fixes #22597

PR checklist

  • Read the contribution guidelines.
  • Added generator-level regression coverage for the affected TypeScript clients.
  • Rebased onto the fork default branch and kept commits scoped.
  • This targets TypeScript clients and mentions recent TypeScript technical committee members for review.

Technical committee

This PR targets TypeScript clients (typescript-fetch, typescript-axios, and typescript-inversify).

cc @davidgamero @mkusaka @joscha @dennisameling

@hwisu hwisu changed the title Align TypeScript multipart file array handling [typescript] Align multipart file array handling Jun 26, 2026
@hwisu hwisu marked this pull request as ready for review June 26, 2026 02:10

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 18 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread samples/client/others/typescript-fetch/multipart-file-array/docs/DefaultApi.md Outdated
@hwisu hwisu force-pushed the codex-fix-typescript-fetch-multipart-file-array branch from 677941b to cd404a4 Compare June 26, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] TypeScript Client Generator Incorrectly Handles File Arrays in multipart/form-data Requests

1 participant