当前位置: 首页 > 知识库问答 >
问题:

如何使用swagger-ui(springfox-swagger2和springfox-swagger-ui)和springboot应用程序上传多个文件?

牛越
2023-03-14
@ApiParam(name = "file", value = "Select the file to Upload", required = true, allowMultiple=true) 
@RequestPart(value = "file", required = true) List<MultipartFile> file
curl -X POST "http://localhost:8080/test" -H "accept: */*" -H "Content-Type: multipart/form-data" -F "file=@example1.pdf;application/pdf;" -F "file=@example2.pdf;application/pdf;" -F "jsonString={}"
@ApiParam(name = "file", value = "Select the file to Upload", required = true, allowMultiple=true) 
@RequestPart(value = "file", required = true) MultipartFile file

依赖关系:

<!-- swagger -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
</dependency>

共有1个答案

桓瀚
2023-03-14

检查这个链接,我们现在不能...swagger dosent支持这个东西,检查下面的链接

https://github.com/springfox/springfox/issues/1072

,您可以使用邮差,只需选择键作为文件类型,并选择多个文件,就可以了。

 类似资料:
  • 我如何访问生成的swagger-ui.html?或者index.html我似乎在我的项目中找不到这个文件。啊啊!

  • 我使用Spring MVC作为Rest控制器,我已经使用Springfox将Swagger用户界面与我的控制器集成在一起。我希望有一个能够通过Swagger用户界面上传文件的方法。我只需要两个参数,一个对象id的长代理和要上传的文件。 我几乎什么都试过了,但我无法显示文件上传按钮。但是,如果我这样做: 文件上载按钮出现,但在尝试上载文件时,它总是抛出http代码415。此外,我需要输入一个多部分文

  • 我已经将SpringFox依赖项添加到我的Spring Boot项目中,当我打开swagger-ui.html页面时,我可以看到我自己创建的RestControllers的文档,我确实看到了以下文档: 基本错误控制器 默认值 null 如何向default/loginendpoint添加文档?

  • 为了添加更多细节,documentKey和abstractDocument都被注释了。 下面是没有任何注释的DocumentChangeSet类。

  • 我使用的是swagger版本2.2.2。如果我转到地址http://localhost:8080/swagger-ui.html,我将直接获得swagger UI。有没有办法,一个安全层可以增加,像,用户应该提示输入用户id和密码之前,大摇大摆的UI显示?

  • 我希望文档的显示方式类似于它在特定于应用程序的上下文路径下的文档中提到的方式。你能告诉我我错过了什么吗?