您当前的位置: 首页 > 

程序员一灯

暂无认证

  • 1浏览

    0关注

    152博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

swagger2返回泛型

程序员一灯 发布时间:2021-08-18 09:43:01 ,浏览量:1

第一步:返回Result加上泛型注解:Result

@ApiModel(value = "返回结果集")
@JsonInclude(JsonInclude.Include.ALWAYS)
@Data
public class Result implements Serializable {
public Result findById(Integer id)

注意:Order接口也是需要swagger2的属性注释的,类似如下

@ApiModel(value = "Order")
public class Order {

    @ApiModelProperty(value = "主键ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

第二步:增加Controller接口注释

@ApiOperation(value="根据ID查找",notes="根据ID查询RTU设置数据")

要注意没有response,加了就不管用了。下面加了response就是按照response返回了。

@ApiOperation(value="根据ID查找",notes="根据ID查询RTU设置数据",response = Result.class)

maven注解:

		
		
			io.springfox
			springfox-swagger2
			2.9.2
		
		
			com.github.xiaoymin
			swagger-bootstrap-ui
			1.9.6
		
		

最终效果:

关注
打赏
1645367472
查看更多评论
立即登录/注册

微信扫码登录

0.0347s