gpt4 book ai didi

java - Swagger ApiModelProperty 不起作用

转载 作者:行者123 更新时间:2023-12-03 08:22:53 25 4
gpt4 key购买 nike

我有问题 @ApiModelProperty Swagger 。在我的模型中,我使用 @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不工作。谁能帮我解决这个问题。请。谢谢大家!

最佳答案

您是否使用 @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;
}

//...
}

关于java - Swagger ApiModelProperty 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32900551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com