Tapir - Method too large

Viewed 633

Im defining endpoints using tapir however i get the following compilation error.

[info] Compiling 3 Scala sources to /endpoints/target/scala-2.13/classes ... [error] Error while emitting/endpoints/Session$ [error] Method too large: endpoints/Session$. ()V [error] one error found [error] (endpoints / Compile / compileIncremental) Compilation failed [error] Total time: 26 s, completed 12-Mar-2020 15:29:54

 val manualReviewEndpoint: Endpoint[(SessionModel.AuthToken, SessionModel.ManualReview.ManualReviewRequest), ErrorsModel.FailureResponse, SessionModel.ManualReview.ManualReviewResponse, Nothing] = endpoint
    .tag("Sessions")
    .description("Triggers manual review for sessions within date range")
    .post
    .in(auth.bearer)
    .in("sessions" / "trigger-review")
    .in(jsonBody[SessionModel.ManualReview.ManualReviewRequest])
    .out(jsonBody[SessionModel.ManualReview.ManualReviewResponse])
    .errorOut(oneOf(
      statusMapping(StatusCode.BadRequest, jsonBody[ErrorsModel.FailureResponse400]),
      statusMapping(StatusCode.Unauthorized, jsonBody[ErrorsModel.FailureResponse401]),
      statusMapping(StatusCode.NotFound, jsonBody[ErrorsModel.FailureResponse404]),
      statusMapping(StatusCode.UnprocessableEntity, jsonBody[ErrorsModel.FailureResponse422]),
      statusMapping(StatusCode.FailedDependency, jsonBody[ErrorsModel.FailureResponse424]),
      statusMapping(StatusCode.InternalServerError, jsonBody[ErrorsModel.FailureResponse500]),
    ))
2 Answers

It looks like because i had so many endpoints with many statusMappings that it was causing the constructor to become too large.

I fixed this issue by putting manualReviewEndpoint into its own object.

It could be due to large length of endpoint, for me it worked by changing endpoint from 'val' to 'def' Which would look like def manualReviewEndpoint

Related