Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger models Option[Int] to Object while Option[String] is modelled correctly as string

Tags:

scala

swagger

I have the following case class

@ApiModel("StationResponse") case class StationResponse (id: Option[String],
                            @ApiModelProperty(dataType = "double", required = false)
                            longitude: Option[Double])

The longitude field is modelled as "Object" instead of "double"

I tried to override the dataType with @ApiModelProperty but no luck. Thanks for your comments.

I am using Swagger 1.3.12 with Scala 2.11.6

like image 434
Ali Salehi Avatar asked Dec 08 '25 07:12

Ali Salehi


1 Answers

I solved the issue by adding @field annotation along with ApiModelProperty like below:

@ApiModel("StationResponse") 
case class StationResponse (id: Option[String],
                            @(ApiModelProperty@field)(dataType = "double", required = false)
                            longitude: Option[Double])
like image 104
Ali Salehi Avatar answered Dec 11 '25 13:12

Ali Salehi