Swagger ApiModelProperty 不工作
Swagger ApiModelProperty not working
我对 @ApiModelProperty
招摇有异议。在我的模型中,我这样使用 @ApiModelProperty
private static final long serialVersionUID = -7142106197262010406L;
private int brandId;
private String brandName;
private String fullName;
private String webSite;
private String logoUrl;
private String note;
@ApiModelProperty(position = 1, required = true, value="")
public int getBrandId() {
return brandId;
}
public void setBrandId(int brandId) {
this.brandId = brandId;
}
@ApiModelProperty(position = 2, required = true)
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
@ApiModelProperty(position = 3, required = true)
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
@ApiModelProperty(position = 4, required = true)
public String getWebSite() {
return webSite;
}
public void setWebSite(String webSite) {
this.webSite = webSite;
}
@ApiModelProperty(position = 5, required = true)
public String getLogoUrl() {
return logoUrl;
}
public void setLogoUrl(String logoUrl) {
this.logoUrl = logoUrl;
}
@ApiModelProperty(position = 6, required = true)
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
我不明白为什么 @ApiModelProperty
不起作用。谁能帮我解决这个问题。请。谢谢大家!
@ApiModelProperty 应该是字段级别而不是方法级别。
将这些注释移动到您拥有变量声明的顶层。
您是否使用 @ApiModel 注释了您的 class?
@ApiModel
public class Brand{
private String brandName;
//...
@ApiModelProperty(position = 1, required = true, value="")
public int getBrandId() {
return brandId;
}
public void setBrandId(int brandId) {
this.brandId = brandId;
}
//...
}
Class 应该有 @ApiModel 注释和字段,或者 class 的 getter/setters 应该有 @ApiModelProperty 注释。
请参考文档 link - http://docs.swagger.io/swagger-core/apidocs/com/wordnik/swagger/annotations/ApiModelProperty.html
希望有用。
谢谢,
马赫什·马内。
我对 @ApiModelProperty
招摇有异议。在我的模型中,我这样使用 @ApiModelProperty
private static final long serialVersionUID = -7142106197262010406L;
private int brandId;
private String brandName;
private String fullName;
private String webSite;
private String logoUrl;
private String note;
@ApiModelProperty(position = 1, required = true, value="")
public int getBrandId() {
return brandId;
}
public void setBrandId(int brandId) {
this.brandId = brandId;
}
@ApiModelProperty(position = 2, required = true)
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
@ApiModelProperty(position = 3, required = true)
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
@ApiModelProperty(position = 4, required = true)
public String getWebSite() {
return webSite;
}
public void setWebSite(String webSite) {
this.webSite = webSite;
}
@ApiModelProperty(position = 5, required = true)
public String getLogoUrl() {
return logoUrl;
}
public void setLogoUrl(String logoUrl) {
this.logoUrl = logoUrl;
}
@ApiModelProperty(position = 6, required = true)
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
我不明白为什么 @ApiModelProperty
不起作用。谁能帮我解决这个问题。请。谢谢大家!
@ApiModelProperty 应该是字段级别而不是方法级别。 将这些注释移动到您拥有变量声明的顶层。
您是否使用 @ApiModel 注释了您的 class?
@ApiModel
public class Brand{
private String brandName;
//...
@ApiModelProperty(position = 1, required = true, value="")
public int getBrandId() {
return brandId;
}
public void setBrandId(int brandId) {
this.brandId = brandId;
}
//...
}
Class 应该有 @ApiModel 注释和字段,或者 class 的 getter/setters 应该有 @ApiModelProperty 注释。
请参考文档 link - http://docs.swagger.io/swagger-core/apidocs/com/wordnik/swagger/annotations/ApiModelProperty.html
希望有用。
谢谢, 马赫什·马内。