Skip to content

Commit

Permalink
Fix issue #257
Browse files Browse the repository at this point in the history
  • Loading branch information
zarthross committed Oct 9, 2018
1 parent d49234f commit adb9bb2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ private[swagger] class SwaggerModelsBuilder(formats: SwaggerFormats) {
def mkQueryParam[F[_]](rule: QueryMetaData[F, _]): Parameter = {
val required = !(rule.m.tpe.isOption || rule.default.isDefined)

TypeBuilder.DataType(rule.m.tpe) match {
val tpe = if(rule.m.tpe.isOption) rule.m.tpe.typeArgs.head else rule.m.tpe
TypeBuilder.DataType(tpe) match {
case TypeBuilder.DataType.ComplexDataType(nm, _) =>
QueryParameter(
`type` = nm.some,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ class SwaggerModelsBuilderSpec extends Specification {
List(QueryParameter(`type` = "string".some, name = "name".some, required = false))
}

"handle an action with one optional seq query parameter" in {
val ra = fooPath +? param[Option[Seq[String]]]("name") |>> { (s: Option[Seq[String]]) => "" }

sb.collectQueryParams[IO](ra) must_==
List(
QueryParameter(`type` = None, name = "name".some,
items = Some(AbstractProperty(`type` = "string")),
defaultValue = None, isArray = true, required = false)
)
}

"handle an action with one query parameter with default value" in {
val ra = fooPath +? param[Int]("id", 6) |>> { (i: Int) => "" }

Expand Down

0 comments on commit adb9bb2

Please sign in to comment.