Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #257 #259

Merged
merged 2 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
zarthross marked this conversation as resolved.
Show resolved Hide resolved
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