scala - Swagger 将 Option[Int] 建模为 Object,而 Option[String] 被正确建模为字符串

标签 scala swagger

我有以下案例类

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

经度字段被建模为“Object”而不是“double”

我尝试用@ApiModelProperty 覆盖数据类型,但没有成功。感谢您的评论。

我正在使用 Swagger 1.3.12 和 Scala 2.11.6

最佳答案

我通过添加 @field 注释和 ApiModelProperty 解决了这个问题,如下所示:

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

关于scala - Swagger 将 Option[Int] 建模为 Object,而 Option[String] 被正确建模为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31949108/

相关文章:

scala - Spark ML VectorAssembler 返回奇怪的输出

scala - cats.effect.IO 可以排序吗,即它在 Traverse 类型类中吗?

clojure - compojure-api/schema/swagger 中的非必需参数?

json - 如何使用 swagger-node 生成/使用 XML

c# - 网络核心 : Swashbuckle Set operationId Automatically on to Controller Action Method

javascript - 从 scala.js 调用 jquery .each 方法

debugging - 无法解释在 scala shell 中执行的示例的行为

scala - 如何在SLICK中使用SQL “LIKE”运算符

c# - 带有 ASP.NET MVC WebApi 的 Swashbuckle 5.4.0 - swagger 网页内未显示文档

c# - 参数的 Swagger 默认值