swagger-api/swagger-play

Option[T] not entirely supported

Opened this issue · 1 comments

Hi,

Having an implicit body parameter which definition looks like this:

case class SomeDTO(
  name: Option[String],
  aLong: Option[Long],
  aFloat: Option[Float],
  aBoolean: Option[Boolean]
)

And declaration:

@ApiImplicitParams(Array(
    new ApiImplicitParam(value = "xxx", paramType = "body", dataType = "dto.SomeDTO", required = true)
  ))

Result in the following swagger.json file:

"SomeDTO" : {
      "type" : "object",
      "properties" : {
        "name" : {
          "type" : "string"
        },
        "aLong" : {
          "type" : "object"
        },
        "aFloat" : {
          "type" : "object"
        },
        "aBoolean" : {
          "type" : "object"
        }
      }
    },

That is, Option[String] is correctly mapped to string but other Option[Long], Option[Float] and Option[Boolean] are mapped to object which is not correct. They should be mapped to number and boolean.

And then, in the UI, examples for this type are not well presented.

NB: I haven't tested if it's specific to implicit and/or body params or not.