Swagger2文档Integer数据类型显示ref。

新手上路,请多包涵

SpringBoot集成Swagger文档后,Integer的数据类型,在文档中参数的数据类型为ref
有没有什么方法能让参数的类型正常显示为Integer。
image.png

@ApiImplicitParam注解中dataType = "int"这个方法不合理;dataTypeClass=Integer.class也试过,没解决(会变成默认的String)

下面是Controller接口中的Api注解

 @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务单id", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "productModelIdDef", value = "产品型号界定", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "faultTypeDef", value = "故障类型界定", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "faultDetailDef", value = "具体故障界定", required = true, dataType = "String"),
            @ApiImplicitParam(name = "costEval", value = "评估维修费用", required = true, dataType = "BigDecimal"),
            @ApiImplicitParam(name = "costSharing", value = "费用分摊,json格式:[{costSharingType, money}]", dataType = "String"),
            @ApiImplicitParam(name = "shelfLifeOut", value = "是否过保", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "isNormalDamage", value = "是否正常损坏", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "dutyOperateId", value = "责任运营id", dataType = "String")
    })

实体类中定义的属性

public class AsRepairService{
    @ApiModelProperty(value = "id")
    private Integer id;
}
阅读 4.6k
1 个回答

试试不加 dataType = "Integer" 看看,就是整个这个属性都没有,不赋值。

印象里 2.9 版本以后是有这么一个坑来着,还有 Long 类型的也是。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题