Skip to content

Commit

Permalink
Merge pull request #307 from kelnos/fix-circe-trait-discriminator-filter
Browse files Browse the repository at this point in the history
Fix discriminator filter in circe protocol trait generation
  • Loading branch information
kelnos authored May 24, 2019
2 parents a2d7169 + a594a2d commit 9b41f5c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.twilio.guardrail.extract.VendorExtension.VendorExtensible._
import com.twilio.guardrail.languages.LA
import com.twilio.guardrail.protocol.terms.protocol._
import com.twilio.guardrail.terms.framework.FrameworkTerms
import com.twilio.guardrail.terms.{ScalaTerms, SwaggerTerms}
import com.twilio.guardrail.terms.{ ScalaTerms, SwaggerTerms }
import java.util.Locale
import scala.collection.JavaConverters._
import scala.language.higherKinds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ object CirceProtocolGenerator {
testTerms <- (
params
.map(_.term)
.filter(_.name.value != discriminator)
.filter(_.name.value != discriminator.propertyName)
.traverse { t =>
for {
tpe <- Target.fromOption(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class AkkaHttpTextPlainTest extends FunSuite with Matchers with EitherValues wit
def doBar(respond: tests.contentTypes.textPlain.server.akkaHttp.foo.FooResource.doBarResponse.type)(
body: Option[String]
): scala.concurrent.Future[tests.contentTypes.textPlain.server.akkaHttp.foo.FooResource.doBarResponse] = ???
def doBaz(respond: FooResource.doBazResponse.type)(
body: Option[String]
): scala.concurrent.Future[tests.contentTypes.textPlain.server.akkaHttp.foo.FooResource.doBazResponse] = ???
})

val client: HttpRequest => Future[HttpResponse] = Route.asyncHandler(route)
Expand All @@ -80,6 +83,9 @@ class AkkaHttpTextPlainTest extends FunSuite with Matchers with EitherValues wit
} else {
Future.successful(respond.NotAcceptable)
}
def doBaz(respond: FooResource.doBazResponse.type)(
body: Option[String]
): scala.concurrent.Future[tests.contentTypes.textPlain.server.akkaHttp.foo.FooResource.doBazResponse] = ???
})

val client: HttpRequest => Future[HttpResponse] = Route.asyncHandler(route)
Expand All @@ -100,6 +106,9 @@ class AkkaHttpTextPlainTest extends FunSuite with Matchers with EitherValues wit
} else {
Future.successful(respond.NotAcceptable)
}
def doBaz(respond: FooResource.doBazResponse.type)(
body: Option[String]
): scala.concurrent.Future[tests.contentTypes.textPlain.server.akkaHttp.foo.FooResource.doBazResponse] = ???
})

val client: HttpRequest => Future[HttpResponse] = Route.asyncHandler(route)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package generators.Http4s.Client.contentType

import _root_.tests.contentTypes.textPlain.client.http4s.foo.FooClient
import _root_.tests.contentTypes.textPlain.client.{ http4s => cdefs }
import _root_.tests.contentTypes.textPlain.server.http4s.foo.{ DoBarResponse, DoFooResponse, FooHandler, FooResource }
import _root_.tests.contentTypes.textPlain.server.http4s.foo.{ DoBarResponse, DoBazResponse, DoFooResponse, FooHandler, FooResource }
import _root_.tests.contentTypes.textPlain.server.{ http4s => sdefs }
import org.scalatest.{ EitherValues, FunSuite, Matchers }
import org.http4s.dsl.io._
import org.http4s.headers._

import cats.effect.IO
import org.http4s.client.Client
import org.http4s.{ Charset, HttpRoutes, MediaType }
Expand Down Expand Up @@ -53,6 +52,7 @@ class Http4sTextPlainTest extends FunSuite with Matchers with EitherValues {
IO.pure(respond.NotAcceptable)
}
def doBar(respond: DoBarResponse.type)(body: Option[String]): IO[sdefs.foo.DoBarResponse] = ???
def doBaz(respond: DoBazResponse.type)(body: Option[String]): IO[sdefs.foo.DoBazResponse] = ???
})

val client: Client[IO] = Client.fromHttpApp(route.orNotFound)
Expand All @@ -69,6 +69,7 @@ class Http4sTextPlainTest extends FunSuite with Matchers with EitherValues {
} else {
IO.pure(respond.NotAcceptable)
}
def doBaz(respond: DoBazResponse.type)(body: Option[String]): IO[sdefs.foo.DoBazResponse] = ???
})

val client: Client[IO] = Client.fromHttpApp(route.orNotFound)
Expand All @@ -85,6 +86,7 @@ class Http4sTextPlainTest extends FunSuite with Matchers with EitherValues {
} else {
IO.pure(respond.NotAcceptable)
}
def doBaz(respond: DoBazResponse.type)(body: Option[String]): IO[sdefs.foo.DoBazResponse] = ???
})

val client: Client[IO] = Client.fromHttpApp(route.orNotFound)
Expand Down

0 comments on commit 9b41f5c

Please sign in to comment.