[BUG][JAVA][SERVER] In release 6.2.1, spring server generator creates wrong annotation on method parameter for multipart request
Created by: raverone
Description
Spring server genertor creates wrong annotation on method parameter for multipart request. The request have 2 parameters:
- SomeObject param1
- MultipartFile param2
In version 5.4.0 both parameters would be annotated with @RequestPart
. Which is correct.
But starting from version 6.0.0 (until the 6.2.1 at least) param1 would be annotated with @RequestParam
and param2 with @RequestPart
.
In this case, if you make a call to such endpoint, Spring won't be able to convert the request parameters and will throw
org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException:
Failed to convert value of type 'java.lang.String' to required type 'org.example.http.model.SomeObject';
...
no matching editors or conversion strategy found
openapi-generator version
6.2.1
OpenAPI declaration file content or url
Generation Details
Generation is done with the gradle plugin by executing ./gradlew :openApiGenerate
Steps to reproduce
I created a minimal project on github Steps to reproduce the bug:
- clone the repo
- cd into the repo directory
- execute
./gradlew :openApiGenerate
- examine file
build/generated/src/main/java/org/example/bug/http/api/TestApiApi.java
- Expected generated code
default ResponseEntity<SomeResponse> uploadFileAndJson(
@RequestPart(value = "someObject", required = true) SomeObject someObject,
@RequestPart(value = "image", required = true) MultipartFile image
)
-
- Actual generated code
default ResponseEntity<SomeResponse> uploadFileAndJson(
@RequestParam(value = "someObject", required = true) SomeObject someObject,
@RequestPart(value = "image", required = true) MultipartFile image
)
- you can also execute tests with
./gradlew -i :test
. It should pass, but currently it isn't.