Hi! I have a reusable PartialEndpoint
defined with security logic and basic error output. In the final endpoints I have to add some additional errors based on its logic. The problem comes when I use errorOutVariant
method. Additional errors are available in Swagger docs, but when I execute endpoint, then that additional error response cannot be mapped causing 500 Internal server error
. The exception is java.lang.IllegalArgumentException: None of the mappings defined in the one-of output
.
On the other hand, when I use errorOutVariantPrepend
or errorOutVariantsFromCurrent
everything works fine. In some cases I have few errors to add and the best option for me is to use errorOutVariants
method - but it also fails. Am I doing something wrong here?
val secureEndpoint: PartialServerEndpoint[SecurityInputs, String, Unit, HttpError, Unit, Any, Future] =
endpoint
.securityIn(auth.apiKey(header[Option[String]]("Authorization")))
.securityIn(auth.apiKey(header[Option[String]]("TwoFactorToken")))
.errorOut(oneOf[HttpError](badRequest, internal))
.serverSecurityLogic(_ => Future.successful(Right("Foo")))
val notWork = secureEndpoint.get
.in("foo")
.errorOutVariant(notFound)
.serverLogic(_ => _ => Future.successful(Left(NotFoundError())))
val work = secureEndpoint.get
.in("foo" and "valid")
.errorOutVariantPrepend(notFound)
.serverLogic(_ => _ => Future.successful(Left(NotFoundError())))