OpenAPITools / OpenAPITools/openapi-generator
[BUG][SPRING] Reactive generates wrong datatype for MultipartFile
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When I use the optional configuration to use reactive the codegen generates the wrong datatype for a multipartfile.
openapi-generator version
4.2.0
OpenAPI declaration file content or url
Actual
default Mono<ResponseEntity<AttachmentModel>> createAttachment(@ApiParam(value = "") @RequestParam(value="fileName", required=false) String fileName,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, ServerWebExchange exchange) throws Exception {
Expected
default Mono<ResponseEntity<AttachmentModel>> createAttachment(@ApiParam(value = "") @RequestParam(value="fileName", required=false) String fileName,@ApiParam(value = "file detail") @Valid @RequestPart("file") Mono<FilePart> file, ServerWebExchange exchange) throws Exception {
Command line used for generation
<generatorName>spring</generatorName>
<modelNameSuffix>Model</modelNameSuffix>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
<unhandledException>true</unhandledException>
<interfaceOnly>true</interfaceOnly>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<booleanGetterPrefix>is</booleanGetterPrefix>
<reactive>true</reactive>
</configOptions>
Suggest a fix
In the mustache file check for reactive and use the right datatype.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Spring generator templates indicated by the suggested fix, using the reactive=true configuration and the MultipartFile example as the reproduction. Compare the generated parameter type with the expected Mono output, then verify that reactive multipart generation produces the expected signature.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100