i’m sure this is me being dumb, but is there somet...
# http4k
i’m sure this is me being dumb, but is there something i’m missing here to get generic classes to work with lenses? some jackson config magic?
Copy code
import org.http4k.contract.contract
import org.http4k.contract.meta
import org.http4k.core.Body
import org.http4k.core.Method
import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Status.Companion.OK
import org.http4k.core.with
import org.http4k.format.Jackson.auto
import org.http4k.routing.bind
import org.junit.jupiter.api.Test

internal class Http4kGenericsTest {

    data class Result<T>(val body: T)

    data class MyClass(val message: String)

    val bodyLens = Body.auto<Result<MyClass>>().toLens()

    fun `test generic deserialization`() {
        val routes = "/test" bind contract {
            routes += "/generics" meta {
                returning(OK, bodyLens to Result(MyClass("Yo!")), "Test", "Test")
            } bindContract Method.GET to {
                Response(OK).with(bodyLens of Result(MyClass("Hello World!")))

        val response = routes(Request(Method.GET, "/test/generics"))


        val result = bodyLens(response)

the first print statement prints
Copy code
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{"body":{"message":"Hello World!"}}
but the second is throwing class cast as it’s been deserialised into a