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

MATGONZALEZ: define default None in non required params in Routes for… #693

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
@@ -1,8 +1,8 @@
# Generated by API Builder - https://www.apibuilder.io
# Service version: 0.3.47

GET /echoes controllers.Echoes.get(foo: _root_.scala.Option[String], optional_messages: _root_.scala.Option[List[String]], required_messages: List[String])
GET /echoes/arrays-only controllers.Echoes.getArraysOnly(optional_messages: _root_.scala.Option[List[String]], required_messages: List[String])
GET /echoes controllers.Echoes.get(foo: _root_.scala.Option[String], optional_messages: _root_.scala.Option[List[String]] ?= None, required_messages: List[String])
GET /echoes/arrays-only controllers.Echoes.getArraysOnly(optional_messages: _root_.scala.Option[List[String]] ?= None, required_messages: List[String])
GET /groups/:organization controllers.Groups.getByOrganization(organization: _root_.java.util.UUID)
POST /members controllers.Members.post()
GET /members controllers.Members.get(guid: _root_.scala.Option[_root_.java.util.UUID], organization_guid: _root_.scala.Option[_root_.java.util.UUID], user_guid: _root_.scala.Option[_root_.java.util.UUID], role: _root_.scala.Option[String])
Expand All @@ -12,6 +12,6 @@ POST /organizations controllers.Organizations.post(
GET /organizations controllers.Organizations.get(guid: _root_.scala.Option[_root_.java.util.UUID], name: _root_.scala.Option[String])
GET /organizations/:guid controllers.Organizations.getByGuid(guid: _root_.java.util.UUID)
POST /users controllers.Users.post()
GET /users controllers.Users.get(guid: _root_.scala.Option[_root_.java.util.UUID], organization_guids: _root_.scala.Option[List[Long]], age_group: _root_.scala.Option[io.apibuilder.reference.api.v0.models.AgeGroup], email: _root_.scala.Option[String], active: Boolean ?= true)
GET /users controllers.Users.get(guid: _root_.scala.Option[_root_.java.util.UUID], organization_guids: _root_.scala.Option[List[Long]] ?= None, age_group: _root_.scala.Option[io.apibuilder.reference.api.v0.models.AgeGroup], email: _root_.scala.Option[String], active: Boolean ?= true)
GET /users/:age_group controllers.Users.getByAgeGroup(age_group: io.apibuilder.reference.api.v0.models.AgeGroup)
POST /users/noop controllers.Users.postNoop()
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ private[models] case class Play2Route(
case ScalaDatatype.Option(_) => None
case p: ScalaPrimitive => Some("?= " + defaultForPrimitive(p, d))
}
).orElse(
param.datatype match {
case ScalaDatatype.Option(ScalaDatatype.List(_)) => Some("?= None")
case ScalaDatatype.Option(ScalaDatatype.Map(_)) => Some("?= None")
case _ => None
}
)
).flatten.mkString(" ")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Play2RouteGeneratorSpec extends AnyFunSpec with Matchers {
val op = getScalaMethod(ssd, "Echoes", Method.Get, "/echoes")
val r = Play2Route(ssd, op, echoResource)
r.method should be("controllers.Echoes.get")
r.params.mkString(", ") should be("foo: _root_.scala.Option[String], optional_messages: _root_.scala.Option[List[String]], required_messages: List[String]")
r.params.mkString(", ") should be("foo: _root_.scala.Option[String], optional_messages: _root_.scala.Option[List[String]] ?= None, required_messages: List[String]")

Play2RouteGenerator(InvocationForm(service)).invoke() match {
case Left(errors) => fail(errors.mkString(", "))
Expand Down
Loading