我正在使用Spring MVC(通过Spring Boot)并使用swagger-spring-mvc库集成了Swagger API文档。如何将@ApiModelProperty dataType设置为Swagger文档的字符串
我有一个类,它看起来是这样的:
@ApiModel
public class CartItem {
...
private Money listPrice; // joda money class
@JsonSerialize(using = )
@ApiModelProperty(required = true, dataType = "")
public Money getListPrice() {
return listPrice;
}
...
}
由于我使用的是ToStringSerializer这个领域,它返回的JSON ,换句话说:
{
"listPrice": "USD 10.50"
}
但是,swagger文档不符合dataType =“”。这表明作为响应模型:
"CartItem": {
"description": "",
"id": "CartItem",
"properties": {
"listPrice": {
"required": false,
"type": "Money"
}
}
}
我试图把@ApiModelProperty注释场上以及方法,并在这两种情况下required场得到尊重,但dataType场被忽略。我也尝试过使用“字符串”,“字符串”和“”作为数据类型,但都没有工作。
我错过了什么,或者这只是swagger-spring-mvc库中的一个错误?
2015-03-30
nerdherd