Swagger @ApiModelProperty必填字段似乎被忽略(版本1.3.6)

时间:2014-12-14 09:55:50

标签: java swagger

必填字段将被忽略,并且不会生成。 例如,对于属性a

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;

import com.wordnik.swagger.annotations.ApiModel;
import com.wordnik.swagger.annotations.ApiModelProperty;

    @XmlRootElement
    @XmlAccessorType(XmlAccessType.FIELD)
    @ApiModel( value = "aaa")
    public class A implements IA
    {
        @ApiModelProperty( value = "bla", required = true )
        @XmlElement(name="a")
        private String a;


         public String getC() { return "kkk";};
}

2 个答案:

答案 0 :(得分:2)

似乎您应该切换注释的顺序!

而不是

        @ApiModelProperty( value = "bla", required = true )
        @XmlElement(name="a")
        private String a;

           @XmlElement(name="a")
           @ApiModelProperty( value = "bla", required = true )
            private String a;

对我来说似乎是一个错误。希望能在新版本中修复

答案 1 :(得分:0)