I use Spring MVC (via Spring Boot) and integrated the Swagger API documentation using the swagger-spring -mvc library.
I have a class that looks something like this:
@ApiModel public class CartItem { ... private Money listPrice;
Since I use ToStringSerializer for this field, it returns listPrice.toString in JSON, in other words:
{ "listPrice": "USD 10.50" }
However, the swagger documentation does not honor dataType = "java.lang.String". It displays the response model as:
"CartItem": { "description": "", "id": "CartItem", "properties": { "listPrice": { "required": false, "type": "Money" } } }
I tried putting the @ApiModelProperty annotation in the field as well as the method, and in both cases the required field is respected, but the dataType field dataType ignored. I also tried using "String", "string" and "java.lang.String" for dataType, but none of them worked.
Am I missing something, or is it just a bug in the swagger-spring-mvc library?
source share