OpenAPITools / OpenAPITools/openapi-generator

[BUG][SPRING] Reactive generates wrong datatype for MultipartFile

Open
#4,463 0 comments 2 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.