swagger踩坑之请求类不显示具体字段
省流:枚举字段需要加上@ApiModelProperty注解
过程复现:
TestEnum 枚举不加注解,swagger的UI类不显示详细字段
@Data
@Accessors(chain = true)
@ApiModel(value = "test对象", description = "test")
public class TestParam implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private String id;
@ApiModelProperty(value = "编码")
private String code;
@ApiModelProperty(value = "名称")
private String name;
@Dict(dicCode = "TestEnum")
// @ApiModelProperty(value = "枚举状态", hidden = true)
private TestEnum testStatus;
}
图示
TestEnum 枚举添加注解,详细字段出现。
经过测试,把String类型字段的注解去掉,字段生成不受影响。
@Data
@Accessors(chain = true)
@ApiModel(value = "test对象", description = "test")
public class TestParam implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private String id;
@ApiModelProperty(value = "编码")
private String code;
// @ApiModelProperty(value = "名称")
private String name;
@Dict(dicCode = "TestEnum")
@ApiModelProperty(value = "枚举状态", hidden = true)
private TestEnum testStatus;
}
图示