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

Multiple file upload Flux<FilePart> error on the swagger-ui #678

Closed
oursy opened this issue May 20, 2020 · 3 comments
Closed

Multiple file upload Flux<FilePart> error on the swagger-ui #678

oursy opened this issue May 20, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@oursy
Copy link

oursy commented May 20, 2020

Given the following endpoint:

  @PostMapping(value = "/files", produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
    @Operation(summary = "files")
    public Flux<Void> handleFileUpload(
            @RequestPart("files") @Parameter(description = "files",
                    content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE))
                    Flux<FilePart> filePartFux) throws IOException {
        File tmp = File.createTempFile("tmp", "");
        return filePartFux.flatMap(filePart -> {
            Path path = Paths.get(tmp.toString() + filePart.filename());
            System.out.println(path);
            return filePart.transferTo(path);
        });
    }

Calling with swaggee-ui returns failure

image

I am using springdoc 1.3.9 & spring boot 2.3.0

@bnasslahsen bnasslahsen changed the title @RequestPart("files") Flux<FilePart> upload error @RequestPart("files") Flux<FilePart> upload error on the swagger-ui May 20, 2020
@bnasslahsen
Copy link
Contributor

@oursy,

The generated OpenAPI documentation looks correct.
The problem seems from the request on the swagger-ui.
It needs further investigations to be sure if the issue is on springdoc-openapi or on swagger-ui side.

@bnasslahsen
Copy link
Contributor

@oursy,

I confirm the generated spec is correct, for your sample.

There is an open feature related to uploading files from the swagger-ui. Once fixed, we will add reference to the last version of the ui on springdoc-openapi.

There is an open feature request on the swagger-ui project. And here is the link for the right issue to follow:

@bnasslahsen bnasslahsen changed the title @RequestPart("files") Flux<FilePart> upload error on the swagger-ui Multiple file upload Flux<FilePart> error on the swagger-ui Jun 7, 2020
@bnasslahsen
Copy link
Contributor

The fix will be available on v1.4.1.

@bnasslahsen bnasslahsen added the bug Something isn't working label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants