These are chat archives for hseeberger/akka-http-json

30th
Nov 2016
onnoll
@onnoll
Nov 30 2016 18:04

Hi there,

I'm trying to make work the circe-generic-extras and I found a problem that I cannot solve if you guys have some experience with a similar case and could help me the would awesome

The case is that I have a file with an Object like this:

...
import io.circe.generic.extras.Configuration

object SegmentProtocol {

  final case class AddSegment(name: String, description: String, conditions: List[SegmentCondition])

  sealed trait SegmentCondition {
    def operator: String
    def value: Any
  }

  final case class Gender(operator: String, value: List[String]) extends SegmentCondition
  final case class GuestIdentification(operator: String, value: List[String]) extends SegmentCondition

  implicit val customConfig: Configuration =
    Configuration.default.withSnakeCaseKeys.withDefaults.withDiscriminator("attribute")
}

and then the file with the routes like this:

...
def route(segmentFacade: ActorRef, segmentFacadeTimeout: Timeout): Route = {
    import CirceSupport._
    import io.circe.generic.extras.auto._
    import io.circe.java8.time._
    import SegmentProtocol._

    def segments = pathPrefix("segments") {
      pathEnd {
        post {
          entity(as[AddSegment]) { addSegment =>
            ...
            }
          }
        }
      }
    }
...

And it fails at compilation with could not find implicit value for parameter um: akka.http.scaladsl.unmarshalling.FromRequestUnmarshaller[....SegmentProtocol.AddSegment]

onnoll
@onnoll
Nov 30 2016 18:11
It works if I add the content of SegmentProtocol in the Object that contains the route method
Heiko Seeberger
@hseeberger
Nov 30 2016 18:25
Hmm ... you might have to add import io.circe.generic.auto._ to the scope of route. Just guessing ...