[BUG] [Spring] Generated API interface treats multipart arrays as a single file
Created by: galleog
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
Generated API interface for multipart arrays contains a single MultipartFile instead of a list. Besides any MultipartFile argument should have @RequestPart annotation instead of @RequestParam.
openapi-generator version
Tested with 4.0.0 version of https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin
OpenAPI declaration file content or url
openapi: '3.0.0'
info:
version: 1.0.0
title: MultipartFile test
paths:
/multipart-array:
post:
tags:
- multipart
description: MultipartFile array test
operationId: multipartArray
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
files:
type: array
items:
type: string
format: binary
responses:
'204':
description: Successful operation
/multipart-single:
post:
tags:
- multipart
description: Single MultipartFile test
operationId: multipartSingle
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
'204':
description: Successful operation
Command line used for generation
Maven plugin was used:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${basedir}/src/main/resources/multipart.yaml</inputSpec>
<generatorName>spring</generatorName>
<modelPackage>org.openapi.test.model</modelPackage>
<apiPackage>org.openapi.test.api</apiPackage>
<library>spring-cloud</library>
<generateSupportingFiles>false</generateSupportingFiles>
<generateApiTests>false</generateApiTests>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<dateLibrary>java8</dateLibrary>
<java8>true</java8>
<booleanGetterPrefix>is</booleanGetterPrefix>
<useBeanValidation>true</useBeanValidation>
<useTags>true</useTags>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
Generate MultipartApi interface using the plugin configuration listed above. Both multipartArray and multipartSingle methods contains a single MultipartFile parameter with @RequestParam annotation.
Related issues/PRs
Suggest a fix
Looks like the mustache template formParams.mustache ignores arrays.