根据Swagger 1.x documentation,我在模型类上使用了@ApiModel
和@ApiModelProperty
:
// @XmlRootElement(name="TempUser")
@ApiModel(value="Tempuser", description="Sample model for the documentation")
public class Tempuser {
@ApiModelProperty( value = "Person's first name", required = true )
private String name;
public Tempuser(String name) {
this.name = name;
}
// @XmlElement(name = "name")
// @ApiModelProperty(example = "peter", required = true)
public String getName() {
return name;
}
public void setType(String name) {
this.name = name;
}
public static Tempuser valueOf(String name) {
return new Tempuser(name);
}
}
我已经尝试通过注释和取消注释@XmlRootElement
,但是Swagger UI不在模型列表中显示此类。该软件包已添加到扫描列表中。