I’m trying to follow the example at One-of variants — Tapir 1.x documentation but I’m getting
IllegalArgumentException Cannot decode: Mismatch(500,404)
instead of the expected Left[ErrorInfo,Unit]
. My endpoint looks like
ndpont
.get
.in("_ready")
.in(query[List[String]]("checked"))
.out(statusCode(StatusCode.Ok))
.errorOut(
oneOf[ErrorInfo](
oneOfVariant(statusCode(StatusCode.InternalServerError).and(jsonBody[ReadyCheckFailed])), //Failed a ready check oneOfVariant(statusCode(StatusCode.NotFound).and(jsonBody[NotFound])), //404 when there's no /_ready oneOfVariant(statusCode(StatusCode.Unauthorized).and(jsonBody[Unauthorized])), //sometimes a 401 when there's no /_ready oneOfVariant(statusCode(StatusCode.InternalServerError).and(jsonBody[InternalServerError])), //Some other 500
)
)
with
sealed trait ErrorInfo case class ReadyCheckFailed(failedChecks:List[String]) extends ErrorInfo
case class NotFound(what: String) extends ErrorInfo
case class Unauthorized(realm: String) extends ErrorInfo
case class InternalServerError(msg: String) extends ErrorInfo
What did I miss?
Thanks,
David