Swagger UI how to display upload of multiple files

2k views Asked by At

I've a Spring MVC application that is wrapped with Swagger annotations.

<spring.version>4.1.8.RELEASE</spring.version>
<java-version>1.7</java-version>
<springfox-version>2.1.2</springfox-version>

I've a controller with two resource endpoints to allow file upload - one endpoint for a single file upload and other with multiple file upload.

Single file upload -->

public @ResponseBody UploadAPIResponse postInboundFile(
                    @ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file,
                    @ApiParam(value = "Inbound trigger flag ") @RequestParam("triggerInbound") Boolean triggerInbound)
                    throws SQLException, Exception {

Multi file upload -->

public @ResponseBody BulkUploadAPIResponse postInboundFilesAsync(
                    @ApiParam(value = "files to upload") @RequestParam("files") MultipartFile[] files,

                    @ApiParam(value = "Inbound trigger flag ") @RequestParam("triggerInbound") Boolean triggerInbound,

                    HttpServletRequest request) throws SQLException, Exception {

On viewing the Swagger UI for the api documentation, I see that for single file upload API, against the "file" parameter, I get a file upload button.

However for the multi file upload API, I get the "files" parameter as a text box.

Can someone pls help me how can I get a file upload button against the "files" parameter of multi-files upload API and I'm able to upload multiple files as part of single request ?

I've gone through various other posts on this context but not able to find a concrete approach to address this issue.

PS : I've the understanding that naming the parameter as "file" provides the file upload button automatically through Swagger-UI. I tried to use the parameter name as "file" instead of "files" for the multi-file upload API but that didn't help; i still end up getting a text box (probably reason being that argument is an array of MultipartFile).

Thanks in advance for any pointers/suggestions.

0

There are 0 answers