Swagger ApiModelProperty 不起作用 [英] Swagger ApiModelProperty not working

查看:95
本文介绍了Swagger ApiModelProperty 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 @ApiModelProperty 时遇到了问题.在我的模型中,我像这样使用 @ApiModelProperty

I have a problem with @ApiModelProperty in swagger. In my model, I use @ApiModelProperty like this

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 不起作用.谁能帮我解决这个问题.请.谢谢大家!

I don't understand why @ApiModelProperty not working. Who can help me how to resolve this problem. Please. Thanks everyone!

推荐答案

您是否使用 @ApiModel 注释您的类?

Did you annotate your class with @ApiModel ?

@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;
    }

    //...
}

这篇关于Swagger ApiModelProperty 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆