Razvan
08/12/2021, 8:43 AMprivate 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
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...@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)private val contractRoutes = listOf(
createTokenRoute()
)