我是靠谱客的博主 完美冬瓜,这篇文章主要介绍【Knife4j】解决SpringBoot整合Knife4j 3.0.3 文件上传不显示文件域一、环境版本二、问题三、解决方案,现在分享给大家,希望可以做个参考。
一、环境版本
- SpringBoot 2.5.2
- Knife4j 3.0.3
二、问题
使用Knife4j
用来配置接口文档注解的时候,文件上传加不上去,使用注解@ApiParam
的type
或者format
都不行。
三、解决方案
先看源码,位置在/Users/diandianxiyu_geek/.m2/repository/org/springframework/spring-web/5.3.8/spring-web-5.3.8.jar!/org/springframework/web/bind/annotation/RequestPart.class
。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23package org.springframework.web.bind.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; @Target({ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface RequestPart { @AliasFor("name") String value() default ""; @AliasFor("value") String name() default ""; boolean required() default true; }
控制器用法如下,亲测可用。
复制代码
1
2
3
4
5
6@ApiOperation(value = "导入") @PostMapping("/import") public void importFile(@RequestPart @RequestParam("file") MultipartFile file){ }
最后生成的文档如下。
最后
以上就是完美冬瓜最近收集整理的关于【Knife4j】解决SpringBoot整合Knife4j 3.0.3 文件上传不显示文件域一、环境版本二、问题三、解决方案的全部内容,更多相关【Knife4j】解决SpringBoot整合Knife4j内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复