Comments (13)
虽然你提了问题,但是我不知道提了什么问题。作者如何复现?
from knife4j.
假设我定义一个接口返回类型,字段 data
是泛型
public class ApiBaseDTO<T> implements Serializable {
private int code;
private String msg;
private String extra;
private boolean success;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime time = LocalDateTime.now();
private T data;
}
然后,在控制器定义返回类型:
接口A:
@Operation(summary = "获取详情")
@GetMapping("/getOneDetailById")
ApiBaseDTO<Entity1> getOneDetailById(@RequestParam(required = false) Integer id) {
return entity1Service.getOneDetailById(id);
}
接口B:
@Operation(summary = "获取详情")
@GetMapping("/getOneDetailById")
ApiBaseDTO<Entity2> getOneDetailById(@RequestParam(required = false) Integer id) {
return entity2Service.getOneDetailById(id);
}
在渲染的文档中,所有接口的data字段的Schema都是同一个,且随机。
原来的Spring Boot 2.7 + knife4j-spring-boot-starter 3.0.3则是正常的。
from knife4j.
from knife4j.
demo无法复现
from knife4j.
from knife4j.
from knife4j.
我出现问题是 Spring Boot3
版本,我的Spring Boot 2.7.18
也是正常的。
from knife4j.
我把项目中多余内容删除,可以复现问题:
所有接口的data字段的schema都是同一个,本该是不同的schema
from knife4j.
降级到 Spring Boot 2.7.18也会有问题,带 jakarta
的依赖的版本就有此问题
from knife4j.
上面的例子就是2.7.18版本,正常的
from knife4j.
Spring Boot 3.2.3
Knife4j 4.5.0
基于你给的代码也没测出来
from knife4j.
@Schema
注解的作用是重命名,条件是必须全局唯一,这种场景下,在泛型类上面用这个注解是不合适的,需要去掉
@Slf4j
@Data
public class ApiBaseDTO<T> implements Serializable {
//....
}
from knife4j.
好的,已解决,谢谢
from knife4j.
Related Issues (20)
- 什么时候升级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 2
- 使用文档下载文件报错,使用apifox、postman可以正常下载 HOT 1
- 范型映射类型不正确
- @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
- 对于@Parameter @ModelAttribute @Valid共同注解所获取的数据,在请求时请求数据格式存在问题 HOT 1
- 不支持 `text/event-stream` 文本流 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.