OpenAPITools / OpenAPITools/openapi-generator

[BUG] @RequestPart (sometimes) ignores first argument depending on order

Open
#5,115 0 comments 1 reaction 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

I am working on a file upload endpoint which is supposed to take a file and two string title and description.

Now, it seems that the order changes whether this works or not:

With this order:

@RequestMapping(value = "/tracks", method = RequestMethod.POST)
@ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE))
void postTrack(

        @RequestPart("title") String title,
        @RequestPart("description") String description,
        @RequestPart("file") MultipartFile file

) {
    trackService.storeTrack(file);
}

I am getting

image

Whereas changing it to this order

@RequestPart("file") MultipartFile file,
@RequestPart("title") String title,
@RequestPart("description") String description

I would get

image

openapi-generator version
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>1.1.49</version>
    <exclusions>
        <exclusion>
            <groupId>io.github.classgraph</groupId>
            <artifactId>classgraph</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>io.github.classgraph</groupId>
    <artifactId>classgraph</artifactId>
    <version>4.8.44</version>
</dependency>

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

No repository file or test is named. Reproduce the issue with the shown Java controller and springdoc-openapi-ui 1.1.49 dependency, comparing the two @RequestPart parameter orders; done means multipart handling is consistent regardless of declaration order.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.