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)
- knife4j-aggregation-spring-boot-starter不支持springboot3
- com.github.xiaoymin.knife4j.extend.filter.basic.ServletSecurityBasicAuthFilter.doFilter(ServletSecurityBasicAuthFilter.java:56) 空指针 HOT 2
- Knife4j文档请求异常 HOT 1
- [v4.5.0]Get/Delete参数是否可以默认勾选,如图所示 HOT 14
- 文档如何根据@JsonView 注解 显示必要字段 HOT 1
- doc.html响应示例数据格式混乱 HOT 5
- 通过swagger.v3的注解@ApiResponse定义的Response Content无法展示 HOT 1
- @ApiOperationSupport(ignoreParameters = {"id"})不生效 版本信息如下
- knife4j springboot2.0 + openapi3 部署到服务器上 报错部分资源访问异常 HOT 1
- SpringBoot3 报 javax.servlet.Filter java.lang.ClassNotFoundException错误 HOT 2
- knife4j文档请求异常 HOT 2
- Spring Boot3 版本,接口返回子字段含泛型展示错误 HOT 13
- Kotlin DataClass 解析出重复字段 HOT 3
- knife4j 无法展示多个对象属性
- @Tag name属性 和 @Operation summary属性 字符'/' 在页面中展示时被替换为 '-' HOT 2
- 响应参数及响应实例中不能正确展示 $ref 的值 HOT 2
- yml配置不支持showTagStatus参数,文档前端实现包含这个参数 HOT 3
- knife4j-gateway-spring-boot-starter cannot support fully expanded arguments for predicates HOT 1
- 多层级泛型不显示字段注释 使用spring boot3和spring doc HOT 11
- 生成的md文档,请求参数类型无法正确配置
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.