Scala: How to map Option[Boolean] to boolean

1,803 views
Skip to first unread message

j3d

unread,
Feb 27, 2014, 2:33:22 PM2/27/14
to swagger-sw...@googlegroups.com
Given the following property...

@ApiModelProperty(value = "Whether this is the default address", dataType = "boolean", required = false)
def isDefault: Option[Boolean]

... Swagger renders it like this:

default (Objectoptional): Whether this is the default address

On the other hand if I modify the property like this...

@ApiModelProperty(value = "Whether this is the default address", dataType = "boolean", required = false)
def isDefault: Boolean

... then Swagger renders it correctly:

default (booleanoptional): Whether this is the default address

Is there any way to map Option[Boolean] to boolean?
tx

tony tam

unread,
Feb 28, 2014, 12:53:20 AM2/28/14
to swagger-sw...@googlegroups.com
Because scala's Boolean is an AnyVal, it cannot be detected.  If you use java.lang.Boolean, it can--the right solution is to support the @ApiModelProperty datatype override.  Could you please open a ticket in swagger-core for this?
Reply all
Reply to author
Forward
0 new messages