gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 03:23:02 24 4
gpt4 key购买 nike

我有以下案例类

@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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com