Comments (13)
同求
from apidocx.
目前是支持Map解析范型的,对于Map<T, User>可以会生成KEY的字段,里面包含了User相关字段信息
from apidocx.
目前是支持Map解析范型的,对于Map<T, User>可以会生成KEY的字段,里面包含了User相关字段信息
public class Response extends HashMap<String, Object>
请问这种返回值能否支持文档展示
from apidocx.
请问期望怎么展示了?目前这种情况就是一个object类型
from apidocx.
目前是支持Map解析范型的,对于Map<T, User>可以会生成KEY的字段,里面包含了User相关字段信息
public class Response extends HashMap<String, Object>请问这种返回值能否支持文档展示
是Response里定义了字段,但是解析不出来吗?
from apidocx.
我也遇到类似问题了,目前我们使用ApiResult 包装了Task对象。解析效果如下图所示,目前针对这个情况,我个人感觉是如何通过注解或者其他方案把保证把Task对象正确展示出来,因为目前springboot一般会封装统一的返回。所以针对但是目前解析出来的都是object对象,而不是具体的对象
from apidocx.
目前已经尝试过使用 @return {@link Task} 发现根本不行
ApiResult 数据结构
public class ApiResult {
/**
* 响应状态码
*/
@ApiModelProperty(value = "响应状态码", required = true)
@Schema(description = "响应状态码", required = true)
private Integer code;
/**
* 响应提示
*/
@ApiModelProperty(value = "响应提示消息", required = true)
@Schema(description = "响应提示消息", required = true)
private String message;
/**
* 响应时间戳
*/
@ApiModelProperty(value = "响应时间戳", required = true)
@Schema(description = "响应时间戳", required = true)
private String timestamp = String.valueOf(DateUtils.getTime());
/**
* 响应数据
*/
@ApiModelProperty(value = "响应数据")
@Schema(description = "响应数据")
private Object data;
public ApiResult(Integer code, String message, Object data) {
this.code = code;
this.message = message;
this.data = data;
}
from apidocx.
目前已经尝试过使用 @return {@link Task} 发现根本不行
ApiResult 数据结构
public class ApiResult { /** * 响应状态码 */ @ApiModelProperty(value = "响应状态码", required = true) @Schema(description = "响应状态码", required = true) private Integer code; /** * 响应提示 */ @ApiModelProperty(value = "响应提示消息", required = true) @Schema(description = "响应提示消息", required = true) private String message; /** * 响应时间戳 */ @ApiModelProperty(value = "响应时间戳", required = true) @Schema(description = "响应时间戳", required = true) private String timestamp = String.valueOf(DateUtils.getTime()); /** * 响应数据 */ @ApiModelProperty(value = "响应数据") @Schema(description = "响应数据") private Object data; public ApiResult(Integer code, String message, Object data) { this.code = code; this.message = message; this.data = data; }
这里data字段应该改为泛型,然后再控制方法使用 ApiResult就可以展示出T的具体类型
from apidocx.
OK。
from apidocx.
@lkqm 我们团队内部已经沟通了,因为目前ApiResult 引用的项目太多了,如果修改成泛型,改动影响比较大。大佬你看能不能改成数据从@return {https://github.com/link Task} 获取,不过他的优先级比使用泛型的优先级低呢或者新增一个静态配置,只有设置这个配置,才会使用@return {https://github.com/link Task} 获取相应呢?
from apidocx.
@gclm 改成泛型不会影响调用方的,默认不传泛型就会当作Object类型。另外你说的方案主要问题在于对于插件来说不知道ApiResult.data
需要被return指定的替换,虽然可以通过配置来实现,但是这样使用从你的场景来看没有必要这样做。
from apidocx.
目前是会影响到调用方的,目前我们调用已经封装成这样了,如果穿泛型的话,目前这个函数实例化就是一个问题。我一会先看看目前插件的代码?如果你这边暂时不好改的话,我fork一份,针对这个场景做个自定义主持吧。
from apidocx.
public class ApiResult {
/** * 响应状态码 */ @ApiModelProperty(value = "响应状态码", required = true) @Schema(description = "响应状态码", required = true) private Integer code; /** * 响应提示 */ @ApiModelProperty(value = "响应提示消息", required = true) @Schema(description = "响应提示消息", required = true) private String message; /** * 响应时间戳 */ @ApiModelProperty(value = "响应时间戳", required = true) @Schema(description = "响应时间戳", required = true) private String timestamp = String.valueOf(DateUtils.getTime()); /** * 响应数据 */ @ApiModelProperty(value = "响应数据") @Schema(description = "响应数据") private Object data; public ApiResult(Integer code, String message, Object data) { this.code = code; this.message = message; this.data = data; }
试试下面这种该法
public class ApiResult<T> {
/**
* 响应状态码
*/
private Integer code;
/**
* 响应提示
*/
private String message;
/**
* 响应时间戳
*/
private String timestamp;
/**
* 响应数据
*/
private T data;
public ApiResult(Integer code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public static <T> ApiResult<T> ok(T data) {
return new ApiResult<T>(200, "ok", data);
}
}
from apidocx.
Related Issues (20)
- 在IDEA 2023.1中访问rap2报错 HOT 4
- swagger解析问题 HOT 1
- 想要在yapi中生成的接口中添加header参数 接口定义里应该怎么写? HOT 1
- 用idea打开项目代码没有智能提示是为什么 HOT 5
- 建议支持swagger注解@ApiImplicitParam HOT 1
- 能否支持validation注解 HOT 1
- 最新版1.1.3怎么没有本地安装包呢 HOT 3
- idea2022.3.3 使用rap2上传卡死 HOT 9
- 新增接口推送策略问题
- 建议备注中枚举显示枚举的值而不是枚举的名称 HOT 1
- yapi 上传问题 HOT 2
- 可以适配其他注解吗,例如JAX-RS HOT 2
- 请问,字段的注释过长,换行了无法显示,该怎么处理呢? HOT 1
- 您好,我的项目中返回的结果包装类中带有范型,导入到YAPI后响应结果为空 HOT 3
- IDEA 2023.2.5版本,无法上传 HOT 3
- idea上传yapi异常 HOT 2
- 您好,请问我们copy markdown可以一起生成一个返回示例吗 HOT 7
- 你好,上传showdoc的时候一直提示验证码错误 HOT 7
- 建议枚举文档支持枚举的方法 HOT 1
- swagger的@Schema注解无法识别
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 apidocx.