Comments (6)
以上问题我已经修改过DApiUI.js来修复此问题,已实现@ApiModelProperty注解中required无效的问题,同时增加了example显示列,当然修改以上代码是不够的,还需要修改后台代码,后台代码可以参考我的文章
https://my.oschina.net/honesty/blog/1838007
@yidao620c @xiaoymin
from knife4j.
你好,原始传参,如果使用的是
public RestMessage reqbody(@requestbody ReqEntity reqEntity)
这种接收实体类的,即使ReqEntity对象定义ApiModelProperty,因为swagger解析出来的json没有该字段,所以展现出来默认给处理成true了
如果用参数的形式 比如
public RestMessage deletetest(@RequestParam(value = "code") String code)
这种,设置required是有效的
这里我是改成将实体类字段解析出来,针对写了ApiModelProperty注解的中文字段解析出来
swagger的默认ui处理就是一个json,字段没有列出
from knife4j.
根据swagger的响应,目前已可以显示,使用版本1.7.7,欢迎升级反馈,谢谢:)
谢谢@AKcheng的建议
from knife4j.
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.5</version>
</dependency>
也存在上述问题。
如果我试用@PostMapping和@requestbody的方式定义rest api接口,doc.html上的 Swagger Models 显示属性都是false
,我看到接口上有单独的required
字段,并且也和@ApiModelProperty定义的一致。
请问这个版本可以解决吗?我们正在使用springboot 2.1.18
from knife4j.
我用的2.0.5 版本,也是存在不能显示 required=true的情况
Spring boot 版本
org.springframework.boot
spring-boot-starter-parent
2.1.7.RELEASE
knife4j版本
com.github.xiaoymin
knife4j-spring-boot-starter
2.0.5
from knife4j.
我用的2.0.5 版本,也是存在不能显示 required=true的情况
Spring boot 版本 org.springframework.boot spring-boot-starter-parent 2.1.7.RELEASE
knife4j版本 com.github.xiaoymin knife4j-spring-boot-starter 2.0.5
2.0.5存在这个bug,后面的版本修复了,可以参考一下版本日志
https://xiaoym.gitee.io/knife4j/changelog/
另外如果Spring Boot的版本太低,可以考虑单纯用新版本的ui,排除掉老的,例如
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<exclusions>
<!--排除老的->
<exclusion>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-ui</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--使用新的->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-ui</artifactId>
<version>2.0.9</version>
</dependency>
from knife4j.
Related Issues (20)
- #716问题在版本较高的boot下依然存在,使用boot3.2.2+knife4j4.5.0 HOT 2
- 求救,升级springboot3后多个对象识别为arg0、arg1 HOT 1
- 什么时候升级ClassGraph,io.github.classgraph版本低 HOT 1
- knife4j UI 不支持swagger3 @RequestBody注解支持, 原生ui支持 HOT 1
- favicon.ico 404 Not Found HOT 3
- AfterScript 添加多个header好像被覆盖了
- knife4j页面地址自动携带的#井号 (特殊字符)无法通过spring-security的放行规则,导致页面无法访问, HOT 1
- 关于SpringBoot2.7.18升级到3.2.x后的Knife4j使用的系列问题汇总(已全部解决) HOT 14
- 使用文档下载文件报错,使用apifox、postman可以正常下载 HOT 2
- 范型映射类型不正确
- @ApiModel 显示错误,显示成其他类,@ApiModel 如何确认唯一性?
- @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
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.