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)
- 不支持 `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
- 加入依赖启动报错
- 重写OperationCustomizer方法没有按我的要求自定义排序 HOT 2
- 当参数为枚举列表时,没有展示枚举的可用值
- 可不可关闭前端参数校验吗
- Controller类加上@Validated 注解后无法被扫描到 HOT 2
- 二维数据结构解析异常(List<List<Object>>) HOT 3
- 接口排序不生效 HOT 1
- swagger v2 和 v3版本的内置数据请求接口差异
- SpringBoot3.0.2访问knife4j时,出现:jakarta.servlet.ServletException: Handler dispatch failed: java.lang.NoClassDefFoundError: jakarta/validation/constraints/Min HOT 1
- production为true的时候是否考虑不继续执行JakartaServletSecurityBasicAuthFilter避免不必要的session创建? HOT 2
- 不支持spring最新版本的路径匹配模式
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.