[BUG][JAVA][SPRING] Wrong annotation used for array of referenced object in Multipart request
Created by: MetroMarv
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When we specify the request body as multipart/form-data
and have one property of type array.
The generated annotation for the statusArray
property is "@RequestParam". Which leads to following error in Spring when the endpoint is used:
org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException:
Failed to convert value of type 'java.lang.String' to required type 'List.of<MultipartMixedStatus>';
Expected would be the annotation "@RequestPart" which fixes the Spring error.
openapi-generator version
6.2.1
But the problem was probably introduced in #11449 with version 6.0.0 (thanks to @borsch to figure this out)
OpenAPI declaration file content or url
[...]
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
description: "a file"
type: string
format: binary
statusArray:
type: array
items:
$ref: '#/components/schemas/MultipartMixedStatus'
[...]
Generation Details
We used the Maven plugin with following config
<configuration>
<templateDirectory>openapi-generator-customization</templateDirectory>
<generatorName>spring</generatorName>
<modelNameSuffix>Dto</modelNameSuffix>
<configOptions>
<useSpringBoot3>true</useSpringBoot3>
<documentationProvider>springdoc</documentationProvider>
<useTags>true</useTags>
<useBeanValidation>true</useBeanValidation>
<performBeanValidation>true</performBeanValidation>
<useSpringController>true</useSpringController>
<oas3>true</oas3>
<apiPackage>com.example.api</apiPackage>
<modelPackage>com.example.model</modelPackage>
<invokerPackage>com.example.invoker</invokerPackage>
<interfaceOnly>true</interfaceOnly>
<skipOverwrite>false</skipOverwrite>
</configOptions>
</configuration>
Steps to reproduce
See test in PR #14450.
Related issues/PRs
- #14295 (closed) fixed the problem for not wrapped objects
- #11449 might have introduced the problem
Suggest a fix
Fixed by: #14450