Skip to content

Map array of binary strings to List<MultipartFile> - #387

Merged
jemacineiras merged 2 commits into
sngular:mainfrom
joseegman-idoneea:fix/multipart-array-binary-mapping
Jul 31, 2026
Merged

Map array of binary strings to List<MultipartFile>#387
jemacineiras merged 2 commits into
sngular:mainfrom
joseegman-idoneea:fix/multipart-array-binary-mapping

Conversation

@joseegman-idoneea

@joseegman-idoneea joseegman-idoneea commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What

Fixes the mapping of arrays of binary strings (multiple file upload) in the OpenAPI generator. They were generated as List<String> instead of List<MultipartFile>.

Closes #386.

Why

ModelBuilder.processArray(...) resolved the element type of simple array items through MapperUtil.getSimpleType(...), which has no binary detection. A single binary property was already handled correctly (MultipartFile via processStringProperty), but the array path fell through to String.

Change

  • ModelBuilder.processArray: detect binary array items with ApiTool.isBinary(items) and map them to TypeConstants.MULTIPART_FILE. ApiTool.isBinary already covers both OpenAPI 3.0 (format: binary) and 3.1 (contentEncoding / contentMediaType). The MultipartFile import is added automatically since getTypeImports walks the inner type of the collection.

Test

  • Added an attachments: array of {string, binary} property to the Document schema in the existing testSimpleBuild fixture, and updated the asserted golden DocumentDTO.java to expect List<MultipartFile>.
  • Full engine suite green: Tests run: 118, Failures: 0, Errors: 0.

Before / after

// before
private List<String> attachments;
// after
private List<MultipartFile> attachments;

🤖 Generated with Claude Code

Version

Bumps the project version 6.6.06.6.1 (patch, bugfix) across the engine, Maven plugin and Gradle plugin.

processArray resolved simple array item types via MapperUtil.getSimpleType,
which has no binary detection, so `type: array, items: {type: string,
format: binary}` produced List<String>. Detect binary items with
ApiTool.isBinary (covers both OpenAPI 3.0 `format: binary` and 3.1
contentEncoding/contentMediaType) and map them to MultipartFile, matching
the existing scalar-property behaviour in processStringProperty.

Adds an array-of-binary property to the testSimpleBuild Document schema as a
regression test.

Fixes sngular#386

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Array of binary strings (multiple file upload) generates List<String> instead of List<MultipartFile>

2 participants