Tapir - 方法太大
Tapir - Method too large
我正在使用貘定义端点,但是出现以下编译错误。
[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]),
))
看起来是因为我有太多带有许多 statusMapping 的端点,导致构造函数变得太大。
我通过将 manualReviewEndpoint
放入它自己的对象中解决了这个问题。
这可能是由于端点长度过长,对我来说,它通过将端点从 'val' 更改为 'def' 来起作用
看起来像 def manualReviewEndpoint
我正在使用貘定义端点,但是出现以下编译错误。
[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]),
))
看起来是因为我有太多带有许多 statusMapping 的端点,导致构造函数变得太大。
我通过将 manualReviewEndpoint
放入它自己的对象中解决了这个问题。
这可能是由于端点长度过长,对我来说,它通过将端点从 'val' 更改为 'def' 来起作用
看起来像 def manualReviewEndpoint