Hi, I'm getting a bit crazy here, any clue at what...
# http4k
r
Hi, I'm getting a bit crazy here, any clue at what can go wrong ? (yep already invalidated caches) In a file got this contract route:
Copy code
private val bodyTokenResponseLens = Body.auto<TokenResponse>().toLens()

    fun createTokenRoute(): ContractRoute = "/token" meta {
        returning(OK, bodyTokenResponseLens to TokenResponse("A", "B", 1800))
    } bindContract <http://Method.POST|Method.POST> to createTokenHandler2()
    private fun createTokenHandler2(): HttpHandler = { req -> Response(OK) }
try to use it in with a openApi3 render I get a
Copy code
Exception in thread "main" java.lang.NullPointerException
	at org.http4k.contract.RouteMetaDsl.returningStatus(routeMeta.kt:85)
	at org.http4k.contract.RouteMetaDsl.returningStatus$default(routeMeta.kt:83)
If i comment the return line is all OK, if it take the code and move it in test class it runs...
adding a brakpoint in
Copy code
@JvmName("returningStatus")
fun <T> returning(status: Status, body: Pair<BiDiBodyLens<T>, T>, description: String? = null, definitionId: String? = null) {
    returning(ResponseMeta(description
        ?: status.description, Response(status).with(body.first of body.second), definitionId, body.second))
}
i see that the body is Pair(null, object)
Ok I'm dumb... the lens is declared after after another var I was using lisiting the routes
Copy code
private val contractRoutes = listOf(
        createTokenRoute()
    )
I think is not the first time I got screwed by this.... maybe this time I won't forget it ­čśä