Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for @RequestParam for file upload #377

Closed
ghost opened this issue Jan 26, 2020 · 2 comments
Closed

Support for @RequestParam for file upload #377

ghost opened this issue Jan 26, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Jan 26, 2020

The docs for my multipart file-upload endpoint do not seem to get generated correctly.

For this

@RequestMapping(value = "/tracks", method = RequestMethod.POST, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
public @ResponseBody
String postTrack(
        @RequestParam("file") MultipartFile file
) {
    storageService.store(file);
    return "redirect:/";
}

The generated documentation results in

image

This are my maven dependencies:

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

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>1.1.49</version>
</dependency>

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

Running under Spring Boot 2.2.2.RELEASE

Am I missing something or is this broken?

This should've been fixed according to #75

@bnasslahsen
Copy link
Contributor

The cause for the issue is different from #75. @RequestParam for sending files was not yet handled.
The support for @RequestParam for sending files will be available in the next release. v1.2.29.
As a workaround you can remove @RequestParam("file") or use @RequestPart("file") instead: tested with v1.2.28;

Note also, you don't need to declare, both dependencies springdoc-openapi-ui and springdoc-openapi-core: springdoc-openapi-core is by transitivity included in springdoc-openapi-ui.

@bnasslahsen bnasslahsen changed the title MultiPart file upload not generated correctly Support for @RequestParam for file upload Jan 26, 2020
@ghost
Copy link
Author

ghost commented Jan 26, 2020

@bnasslahsen Thank you for clarification! Indeed it worked with @RequestPart! Thank you for also mentioning the redundant dependency!

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant