第一步:返回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
最终效果: