Skip to content

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

Description

@joseegman-idoneea

Description

When an OpenAPI schema declares an array of binary strings (multiple file upload), the generator maps the array items to String instead of MultipartFile, producing List<String> in the generated model.

A single binary property is handled correctly (MultipartFile), so only the array/collection case is affected.

Steps to reproduce

Given a schema property such as:

Document:
  type: object
  properties:
    document:
      type: string
      format: binary
    attachments:
      type: array
      items:
        type: string
        format: binary

Actual result

private MultipartFile document;        // OK
private List<String> attachments;      // wrong

Expected result

private MultipartFile document;
private List<MultipartFile> attachments;

Root cause

ModelBuilder.processArray(...) resolves the element type of a simple (non-$ref, non-composed, no-properties) array item through MapperUtil.getSimpleType(items, ...). getSimpleType has no binary detection (it never calls ApiTool.isBinary), so a { type: string, format: binary } item falls through to "string".

Binary → MultipartFile is only applied for scalar object properties, in ModelBuilder.processStringProperty(...), never for array items.

The same gap applies to the OpenAPI 3.1 style (contentEncoding / contentMediaType), since ApiTool.isBinary already covers both but is not consulted on the array path.

Environment

  • Affects the OpenAPI code generator (multiapi-engine).
  • Reproduced on main.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions