idea 快速生成接口文档
之前使用过小幺鸡,swagger 感觉不太合适自己
-
小幺鸡的话效率太慢了,每次都要复制生成好的json,如果接口做了修改,也要手动去修改小幺鸡的文档
-
swagger 的话 侵入式太强了,感觉有点不习惯例如
-
@Data @ApiModel(description = "仓库回调商品退款参数") @JsonPropertyOrder(alphabetic = true) public class ConcurReturn { @NotBlank(message = "商城订单号不能为空") @ApiModelProperty(value = "商城订单号", required = true, dataType = "String") private String orderNo;
@NotBlank(message = "商城退单号不能为空") @ApiModelProperty(value = "商城退单号", required = true, dataType = "String") private String returnNo; @NotBlank(message = "物流单号不能为空") @ApiModelProperty(value = "物流单号", required = true, dataType = "String") private String expressNumber; @NotBlank(message = "商品sku不能为空") @ApiModelProperty(value = "商品sku", required = true, dataType = "String") private String sku; @NotBlank(message = "仓库名称不能为空") @ApiModelProperty(value = "仓库名称", required = true, dataType = "String") private String warehouseName; @NotNull(message = "仓库id不能为空") @ApiModelProperty(value = "仓库id", required = true, dataType = "int") private Integer warehouseId; @NotNull(message = "收货时间不能为空") @ApiModelProperty(value = "收货时间", required = true, dataType = "Long") private Long receivingTime; @NotNull(message = "仓库实收数量不能为空") @Min(value = 0, message = "实收数量有误") @ApiModelProperty(value = "仓库实收数量 0:为空包裹等,拒绝收货,售后关闭", required = true, dataType = "int") private Integer netReceiptsQty; @Min(value = 0, message = "不良品数量有误") @ApiModelProperty(value = "不良品数量", required = false, dataType = "int") private Integer rejectsQty; @ApiModelProperty(value = "备注", required = false, dataType = "String") private String remarks;
所以说 我用的是yapi,+ idea 的插件easy-yapi
easy-yapi:https://github.com/tangcent/easy-yapi/blob/master/docs/cn/Home.md
- yapi定制版easy-api
- 在easy-api的基础上增加对yapi的支持
- 如果你对easy-api有兴趣或者希望支持其他第三方API管理平台,那么这也是一个很好的例子,通过对比easy-api与easy-yapi的差异,可以了解到如何在 easy-api的基础上开发,使其得以支持第三方API管理平台
yapi相关参数配置
- 在导出过程中如果需要yapi相关参数,将会以弹窗的方式提供输入
- 也可以在Preferences(Settings) > Other Settings > EasyApi 中手动配置
首次使用此插件时,建议开启inferEnable,这将允许插件在遇到不确定的方法返回类型(Object,Some)时尝试通过代码流进行推断,并根据项目需求设置maxDeep(最大推断深度) - 需要提供的参数有
- server 即部署的yapi地址,如:http://127.0.0.1:3000/
- tokens 即yapi项目中用于请求项目openapi的私有token,获取方式为 项目->设置->token 配置 -> 工具标识
yapi:https://github.com/YMFE/yapi
通过 idea–>code
生成接口文档即可