Comments (13)
感谢反馈,我后面有空看一下
ps:其实通过issues反馈交流更好:)
from knife4j.
我又试了一下,@parameters是可行的,参数解释也能出来,这么写试试@parameter(name = "file", description = "文件", required = true, in = ParameterIn.DEFAULT, schema = @Schema(name = "file", format = "binary"))
from knife4j.
文件可以通过这种方式的注解去配置:@parameter(name = "file", description = "文件", required = true, content = @content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE, schema = @Schema(type = "string", format = "binary"))),我试过是可以的。
但问题是如果文件字段是在某个实体类里,这个实体类作为controller方法的参数,那swagger不返回这个文件字段,前端也无法显示。
from knife4j.
@jamesxujoy 你用的也是knife4j-openapi3-jakarta-spring-boot-starter4.5.0的版本么?我本地用你这么配置之后,在doc.html打开中还是不能上传文件,有点囧...以下是本地贴图
1.业务代码(knife4j-openapi3-jakarta-spring-boot-starter 4.5.0实现方式)
2.前端访问(knife4j-openapi3-jakarta-spring-boot-starter 4.5.0实现方式)
PS:
旧版knife4j-spring-boot-starter 3.0.3(升级前的前端正常访问)
旧版knife4j-spring-boot-starter 3.0.3(后端配置)
from knife4j.
@jmszwzr 问题5文件上传不显示的问题,反馈一下解决办法,将@RequestParam改为@RequestPart即可。
我尝试了@parameter修改,@PostMaping中定义consumer,都不生效。最后在issue407找到答案。将@RequestParam改为@RequestPart即可。
from knife4j.
@zhangchaoxu 感谢回复 不过我升级Knife到4.5.0之后,接收file使用的注解还是@RequestPart并没有更改,请查看[1.业务代码(knife4j-openapi3-jakarta-spring-boot-starter 4.5.0实现方式)]
from knife4j.
那就更诡异了,我现在也是用的knife4j-openapi3-jakarta-spring-boot-starter 4.5.0+springboot 3.3.0。
从@RequestParam替换成@RequestPart后,解决了问题。
from knife4j.
@zhangchaoxu 厉害 ,我把我本地接口上的@parameters注解注释掉之后,也是可以的了,原来Knife4j可以自动识别@RequestPart注解;不过这样,对于其他参数,在swagger文档中就没法进行参数说明了,是不是?
from knife4j.
@zhangchaoxu 按照兄台的配置,本地也测试成功了!感谢!
from knife4j.
@zhangchaoxu 兄台,请教你,升级到Knife4j4.5.0之后,你的Controller层排序还能正常吗?我本地使用@apisupport注解排序时发现,第一个分组有问题,第二个分组又是正常的,在F12中看到第一个分组中竟然没有返回tags属性,真的奇怪,不过我推测可能是Knife4j的bug。
附图
图二:分组一和分组二Swagger请求访问排序对比(想让Controller层按照给定的order值进行排序,排序号即是分组Controller中序号值,如1-系统公共方法,那么1就是@apisupport(order = 1)中的order值)
from knife4j.
针对问题2已经有解决方法!
在Gitee中翻看到有同类型问题,在Gitee-I7U2I0中"BlueCup"提到:解决了我的问题,我是前端没有出现tags节点,原来是@tag中没有写description,我的排序可以了。
原来我在系统模块中的Controller中所有接口写了description,但是没有文字描述,导致系统模块在Swagger请求中,没出现tags标签,所以导致在类Controller中的@apisupport设置的值不生效!!
后续:为什么不给@tag中的description进行文字描述,前端请求中就出现不了tags标签,进而导致@apisupport失效,确实是个问题哈~ @xiaoymin
from knife4j.
针对问题3已经得到解决!
见Knife4j从3.0.3升级至4.5.0的记录中的Knife4jConfig配置
,主要就是在GroupedOpenApi的初始化中,增加addOpenApiCustomizer自定义配置,获取到全部Paths后,使用本地封装的将原来的ApiResponses替换掉即可,目前替换的就是常用的put/get/delete/post四种请求方式。
from knife4j.
针对问题4,本地最新数次重启访问Swagger均未复现,且留待看;现在就只剩下问题1了!
from knife4j.
Related Issues (20)
- @ApiModel value 长度限制? HOT 1
- spring doc升级到2.4.0及以后的版本,group-configs异常 HOT 5
- @ApiImplicitParam的allowableValues属性,在@Parameter如何对应,能否提供样例
- 当使用注解时出现未知的描述 HOT 4
- 这个应该你自己查查原因
- 当knife4j-gateway-spring-boot-starter聚合基于dubbo的微服务时 访问v3/api-doc出错 HOT 1
- knife4j文档请求异常 HOT 2
- springboot3整合时swagger可以访问,knife4j页面无法访问
- 导出word格式接口文档,word格式错乱 HOT 1
- 对于@Parameter @ModelAttribute @Valid共同注解所获取的数据,在请求时请求数据格式存在问题 HOT 1
- 不支持 `text/event-stream` 文本流 HOT 1
- 在不使用任何注解的情况下 根据Controller内的书写顺序排序接口
- knife4j-openapi3-ui 不支持Schema.AccessMode.WRITE_ONLY 和 Schema.AccessMode.READ_ONLY
- 问题有些无语
- knife4j-vue打包到非spring项目中,调试-请求参数光标位置不正确的BUG HOT 2
- 希望Knife4jInsight docker容器能支持ARM64架构 HOT 1
- 如果实体类是一个字段比较多,且有循环引用的情况下knife4j会卡死,但是swagger-ui没有该问题。
- 响应参数展示的和实际参数不对
- 当springdoc配置使用use-management-port: true的时候找不到/v3/api-docs/swagger-config
- 加入依赖启动报错
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knife4j.