From 10394494803153e9d1ab284bc94e4767d4a0ff77 Mon Sep 17 00:00:00 2001 From: David van Geest Date: Thu, 6 Apr 2023 14:37:03 -0400 Subject: [PATCH 1/4] Extract tapir-cats-effect module from tapir-cats. --- build.sbt | 35 +++++++++++++++---- .../integ/cats/effect}/CatsMonadError.scala | 2 +- project/Versions.scala | 1 + .../armeria/cats/CatsMonadAsyncError.scala | 2 +- .../armeria/cats/ArmeriaCatsServerTest.scala | 2 +- .../cats/FinatraCatsServerInterpreter.scala | 2 +- .../http4s/Http4sServerInterpreter.scala | 2 +- .../server/http4s/Http4sServerStubTest.scala | 2 +- .../server/http4s/Http4sServerTest.scala | 2 +- .../http4s/ztapir/ZHttp4sServerStubTest.scala | 2 +- .../http4s/ztapir/ZHttp4sServerTest.scala | 2 +- .../http4s/ztapir/ZHttp4sServerStubTest.scala | 2 +- .../http4s/ztapir/ZHttp4sServerTest.scala | 2 +- .../server/netty/cats/NettyCatsServer.scala | 2 +- .../cats/NettyCatsServerInterpreter.scala | 2 +- .../netty/cats/NettyCatsServerStubTest.scala | 2 +- .../netty/cats/NettyCatsServerTest.scala | 2 +- .../vertx/cats/VertxStubServerTest.scala | 2 +- .../tests/AwsLambdaCreateServerStubTest.scala | 2 +- .../runtime/AwsLambdaRuntimeInvocation.scala | 2 +- .../AwsLambdaRuntimeInvocationTest.scala | 2 +- 21 files changed, 48 insertions(+), 26 deletions(-) rename integrations/{cats/src/main/scala/sttp/tapir/integ/cats => cats-effect/src/main/scala/sttp/tapir/integ/cats/effect}/CatsMonadError.scala (95%) diff --git a/build.sbt b/build.sbt index 2c619ae1f2..9dc3c14d51 100644 --- a/build.sbt +++ b/build.sbt @@ -504,8 +504,7 @@ lazy val cats: ProjectMatrix = (projectMatrix in file("integrations/cats")) .settings( name := "tapir-cats", libraryDependencies ++= Seq( - "org.typelevel" %%% "cats-core" % "2.9.0", - "org.typelevel" %%% "cats-effect" % Versions.catsEffect, + "org.typelevel" %%% "cats-core" % Versions.catsCore, scalaTest.value % Test, scalaCheck.value % Test, scalaTestPlusScalaCheck.value % Test, @@ -541,6 +540,28 @@ lazy val cats: ProjectMatrix = (projectMatrix in file("integrations/cats")) ) .dependsOn(core) +lazy val catsEffect: ProjectMatrix = (projectMatrix in file("integrations/cats-effect")) + .settings(commonSettings) + .settings( + name := "tapir-cats-effect", + libraryDependencies ++= Seq( + "org.typelevel" %%% "cats-core" % Versions.catsCore, + "org.typelevel" %%% "cats-effect" % Versions.catsEffect + ) + ) + .jvmPlatform( + scalaVersions = scala2And3Versions + ) + .jsPlatform( + scalaVersions = scala2And3Versions, + settings = commonJsSettings + ) + .nativePlatform( + scalaVersions = scala2And3Versions, + settings = commonNativeSettings + ) + .dependsOn(core) + lazy val enumeratum: ProjectMatrix = (projectMatrix in file("integrations/enumeratum")) .settings(commonSettings) .settings( @@ -1138,7 +1159,7 @@ lazy val armeriaServerCats: ProjectMatrix = ) ) .jvmPlatform(scalaVersions = scala2And3Versions) - .dependsOn(armeriaServer % CompileAndTest, cats, serverTests % Test) + .dependsOn(armeriaServer % CompileAndTest, cats, catsEffect, serverTests % Test) lazy val armeriaServerZio: ProjectMatrix = (projectMatrix in file("server/armeria-server/zio")) @@ -1185,7 +1206,7 @@ lazy val http4sServer: ProjectMatrix = (projectMatrix in file("server/http4s-ser Test / skip := true ) ) - .dependsOn(serverCore, cats) + .dependsOn(serverCore, cats, catsEffect) lazy val http4sServer2_12 = http4sServer.jvm(scala2_12).dependsOn(serverTests.jvm(scala2_12) % Test) lazy val http4sServer2_13 = http4sServer.jvm(scala2_13).dependsOn(serverTests.jvm(scala2_13) % Test) @@ -1267,7 +1288,7 @@ lazy val finatraServerCats: ProjectMatrix = .settings(commonJvmSettings) .settings(name := "tapir-finatra-server-cats") .jvmPlatform(scalaVersions = scala2Versions) - .dependsOn(finatraServer % CompileAndTest, cats, serverTests % Test) + .dependsOn(finatraServer % CompileAndTest, cats, catsEffect, serverTests % Test) lazy val playServer: ProjectMatrix = (projectMatrix in file("server/play-server")) .settings(commonJvmSettings) @@ -1296,7 +1317,7 @@ lazy val nettyServer: ProjectMatrix = (projectMatrix in file("server/netty-serve .jvmPlatform(scalaVersions = scala2And3Versions) .dependsOn(serverCore, serverTests % Test) -lazy val nettyServerCats: ProjectMatrix = nettyServerProject("cats", cats) +lazy val nettyServerCats: ProjectMatrix = nettyServerProject("cats", catsEffect) .settings(libraryDependencies += "com.softwaremill.sttp.shared" %% "fs2" % Versions.sttpShared) lazy val nettyServerZio: ProjectMatrix = nettyServerProject("zio", zio) @@ -1394,7 +1415,7 @@ lazy val awsLambda: ProjectMatrix = (projectMatrix in file("serverless/aws/lambd ) .jvmPlatform(scalaVersions = scala2And3Versions) .jsPlatform(scalaVersions = scala2Versions) - .dependsOn(serverCore, cats, circeJson, tests % "test") + .dependsOn(serverCore, cats, catsEffect, circeJson, tests % "test") // integration tests for lambda interpreter // it's a separate project since it needs a fat jar with lambda code which cannot be build from tests sources diff --git a/integrations/cats/src/main/scala/sttp/tapir/integ/cats/CatsMonadError.scala b/integrations/cats-effect/src/main/scala/sttp/tapir/integ/cats/effect/CatsMonadError.scala similarity index 95% rename from integrations/cats/src/main/scala/sttp/tapir/integ/cats/CatsMonadError.scala rename to integrations/cats-effect/src/main/scala/sttp/tapir/integ/cats/effect/CatsMonadError.scala index 513aaa2031..5cc409a6f0 100644 --- a/integrations/cats/src/main/scala/sttp/tapir/integ/cats/CatsMonadError.scala +++ b/integrations/cats-effect/src/main/scala/sttp/tapir/integ/cats/effect/CatsMonadError.scala @@ -1,4 +1,4 @@ -package sttp.tapir.integ.cats +package sttp.tapir.integ.cats.effect import cats.effect.Sync import sttp.monad.MonadError diff --git a/project/Versions.scala b/project/Versions.scala index 8a9468d4f4..795f10460c 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -2,6 +2,7 @@ object Versions { val http4s = "0.23.18" val http4sBlazeServer = "0.23.14" val http4sBlazeClient = "0.23.14" + val catsCore = "2.9.0" val catsEffect = "3.4.8" val circe = "0.14.3" val circeGenericExtras = "0.14.3" diff --git a/server/armeria-server/cats/src/main/scala/sttp/tapir/server/armeria/cats/CatsMonadAsyncError.scala b/server/armeria-server/cats/src/main/scala/sttp/tapir/server/armeria/cats/CatsMonadAsyncError.scala index f9d973b776..2bbe9bd4e3 100644 --- a/server/armeria-server/cats/src/main/scala/sttp/tapir/server/armeria/cats/CatsMonadAsyncError.scala +++ b/server/armeria-server/cats/src/main/scala/sttp/tapir/server/armeria/cats/CatsMonadAsyncError.scala @@ -3,7 +3,7 @@ package sttp.tapir.server.armeria.cats import cats.effect.Async import cats.syntax.functor._ import sttp.monad.{Canceler, MonadAsyncError} -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError // Forked from sttp.client3.impl.cats.CatsMonadAsyncError private class CatsMonadAsyncError[F[_]](implicit F: Async[F]) extends CatsMonadError[F] with MonadAsyncError[F] { diff --git a/server/armeria-server/cats/src/test/scala/sttp/tapir/server/armeria/cats/ArmeriaCatsServerTest.scala b/server/armeria-server/cats/src/test/scala/sttp/tapir/server/armeria/cats/ArmeriaCatsServerTest.scala index 5033a3e0e1..cd4f904ade 100644 --- a/server/armeria-server/cats/src/test/scala/sttp/tapir/server/armeria/cats/ArmeriaCatsServerTest.scala +++ b/server/armeria-server/cats/src/test/scala/sttp/tapir/server/armeria/cats/ArmeriaCatsServerTest.scala @@ -2,7 +2,7 @@ package sttp.tapir.server.armeria.cats import cats.effect.{IO, Resource} import sttp.capabilities.fs2.Fs2Streams -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.tests._ import sttp.tapir.tests.{Test, TestSuite} diff --git a/server/finatra-server/cats/src/main/scala/sttp/tapir/server/finatra/cats/FinatraCatsServerInterpreter.scala b/server/finatra-server/cats/src/main/scala/sttp/tapir/server/finatra/cats/FinatraCatsServerInterpreter.scala index b172710331..4267bd6d91 100644 --- a/server/finatra-server/cats/src/main/scala/sttp/tapir/server/finatra/cats/FinatraCatsServerInterpreter.scala +++ b/server/finatra-server/cats/src/main/scala/sttp/tapir/server/finatra/cats/FinatraCatsServerInterpreter.scala @@ -5,7 +5,7 @@ import cats.effect.std.Dispatcher import cats.~> import com.twitter.util.Future import sttp.monad.MonadError -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.model.ServerRequest import sttp.tapir.server.ServerEndpoint import sttp.tapir.server.finatra.FinatraServerInterpreter.FutureMonadError diff --git a/server/http4s-server/src/main/scala/sttp/tapir/server/http4s/Http4sServerInterpreter.scala b/server/http4s-server/src/main/scala/sttp/tapir/server/http4s/Http4sServerInterpreter.scala index 7656b4795f..40c8a268b7 100644 --- a/server/http4s-server/src/main/scala/sttp/tapir/server/http4s/Http4sServerInterpreter.scala +++ b/server/http4s-server/src/main/scala/sttp/tapir/server/http4s/Http4sServerInterpreter.scala @@ -12,7 +12,7 @@ import org.http4s.websocket.WebSocketFrame import org.typelevel.ci.CIString import sttp.capabilities.WebSockets import sttp.capabilities.fs2.Fs2Streams -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.ServerEndpoint import sttp.tapir.server.interceptor.RequestResult import sttp.tapir.server.interceptor.reject.RejectInterceptor diff --git a/server/http4s-server/src/test/scala/sttp/tapir/server/http4s/Http4sServerStubTest.scala b/server/http4s-server/src/test/scala/sttp/tapir/server/http4s/Http4sServerStubTest.scala index 7c08098c35..7abe568602 100644 --- a/server/http4s-server/src/test/scala/sttp/tapir/server/http4s/Http4sServerStubTest.scala +++ b/server/http4s-server/src/test/scala/sttp/tapir/server/http4s/Http4sServerStubTest.scala @@ -4,7 +4,7 @@ import cats.effect.IO import cats.effect.unsafe.implicits.global import sttp.capabilities.fs2.Fs2Streams import sttp.client3.testing.SttpBackendStub -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.interceptor.CustomiseInterceptors import sttp.tapir.server.tests.{CreateServerStubTest, ServerStubStreamingTest, ServerStubTest} diff --git a/server/http4s-server/src/test/scala/sttp/tapir/server/http4s/Http4sServerTest.scala b/server/http4s-server/src/test/scala/sttp/tapir/server/http4s/Http4sServerTest.scala index 687bbdd18c..47e5b00f89 100644 --- a/server/http4s-server/src/test/scala/sttp/tapir/server/http4s/Http4sServerTest.scala +++ b/server/http4s-server/src/test/scala/sttp/tapir/server/http4s/Http4sServerTest.scala @@ -13,7 +13,7 @@ import sttp.capabilities.fs2.Fs2Streams import sttp.client3._ import sttp.model.sse.ServerSentEvent import sttp.tapir._ -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.tests._ import sttp.tapir.tests.{Test, TestSuite} import sttp.ws.{WebSocket, WebSocketFrame} diff --git a/server/http4s-server/zio/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerStubTest.scala b/server/http4s-server/zio/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerStubTest.scala index edffdcc11f..f5022f87cd 100644 --- a/server/http4s-server/zio/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerStubTest.scala +++ b/server/http4s-server/zio/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerStubTest.scala @@ -2,7 +2,7 @@ package sttp.tapir.server.http4s.ztapir import sttp.capabilities.zio.ZioStreams import sttp.client3.testing.SttpBackendStub -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.http4s.Http4sServerOptions import sttp.tapir.server.interceptor.CustomiseInterceptors import sttp.tapir.server.tests.{CreateServerStubTest, ServerStubStreamingTest, ServerStubTest} diff --git a/server/http4s-server/zio/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerTest.scala b/server/http4s-server/zio/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerTest.scala index 5b87297e9c..22f502dec4 100644 --- a/server/http4s-server/zio/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerTest.scala +++ b/server/http4s-server/zio/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerTest.scala @@ -9,7 +9,7 @@ import sttp.client3._ import sttp.model.sse.ServerSentEvent import sttp.monad.MonadError import sttp.tapir._ -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.http4s.Http4sServerSentEvents import sttp.tapir.server.tests._ import sttp.tapir.tests.{Test, TestSuite} diff --git a/server/http4s-server/zio1/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerStubTest.scala b/server/http4s-server/zio1/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerStubTest.scala index 94d30c7224..208ab23c30 100644 --- a/server/http4s-server/zio1/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerStubTest.scala +++ b/server/http4s-server/zio1/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerStubTest.scala @@ -2,7 +2,7 @@ package sttp.tapir.server.http4s.ztapir import sttp.capabilities.zio.ZioStreams import sttp.client3.testing.SttpBackendStub -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.http4s.Http4sServerOptions import sttp.tapir.server.interceptor.CustomiseInterceptors import sttp.tapir.server.tests.{CreateServerStubTest, ServerStubStreamingTest, ServerStubTest} diff --git a/server/http4s-server/zio1/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerTest.scala b/server/http4s-server/zio1/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerTest.scala index 73ece5e85a..d848cdd5d3 100644 --- a/server/http4s-server/zio1/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerTest.scala +++ b/server/http4s-server/zio1/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sServerTest.scala @@ -7,7 +7,7 @@ import sttp.client3._ import sttp.model.sse.ServerSentEvent import sttp.monad.MonadError import sttp.tapir._ -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.tests._ import sttp.tapir.tests.{Test, TestSuite} import zio.{RIO, UIO} diff --git a/server/netty-server/cats/src/main/scala/sttp/tapir/server/netty/cats/NettyCatsServer.scala b/server/netty-server/cats/src/main/scala/sttp/tapir/server/netty/cats/NettyCatsServer.scala index 46e587910c..36fa561df6 100644 --- a/server/netty-server/cats/src/main/scala/sttp/tapir/server/netty/cats/NettyCatsServer.scala +++ b/server/netty-server/cats/src/main/scala/sttp/tapir/server/netty/cats/NettyCatsServer.scala @@ -6,7 +6,7 @@ import cats.syntax.all._ import io.netty.channel._ import io.netty.channel.unix.DomainSocketAddress import sttp.monad.MonadError -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.ServerEndpoint import sttp.tapir.server.netty.cats.internal.CatsUtil.{nettyChannelFutureToScala, nettyFutureToScala} import sttp.tapir.server.netty.Route diff --git a/server/netty-server/cats/src/main/scala/sttp/tapir/server/netty/cats/NettyCatsServerInterpreter.scala b/server/netty-server/cats/src/main/scala/sttp/tapir/server/netty/cats/NettyCatsServerInterpreter.scala index 375b839591..84ccd71cff 100644 --- a/server/netty-server/cats/src/main/scala/sttp/tapir/server/netty/cats/NettyCatsServerInterpreter.scala +++ b/server/netty-server/cats/src/main/scala/sttp/tapir/server/netty/cats/NettyCatsServerInterpreter.scala @@ -3,7 +3,7 @@ package sttp.tapir.server.netty.cats import cats.effect.Async import cats.effect.std.Dispatcher import sttp.monad.MonadError -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.ServerEndpoint import sttp.tapir.server.netty.Route import sttp.tapir.server.netty.internal.{NettyServerInterpreter, RunAsync} diff --git a/server/netty-server/cats/src/test/scala/sttp/tapir/server/netty/cats/NettyCatsServerStubTest.scala b/server/netty-server/cats/src/test/scala/sttp/tapir/server/netty/cats/NettyCatsServerStubTest.scala index c847fda1fd..00b456f721 100644 --- a/server/netty-server/cats/src/test/scala/sttp/tapir/server/netty/cats/NettyCatsServerStubTest.scala +++ b/server/netty-server/cats/src/test/scala/sttp/tapir/server/netty/cats/NettyCatsServerStubTest.scala @@ -4,7 +4,7 @@ import cats.effect.IO import cats.effect.std.Dispatcher import cats.effect.unsafe.implicits.global import sttp.client3.testing.SttpBackendStub -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.interceptor.CustomiseInterceptors import sttp.tapir.server.tests.{CreateServerStubTest, ServerStubTest} diff --git a/server/netty-server/cats/src/test/scala/sttp/tapir/server/netty/cats/NettyCatsServerTest.scala b/server/netty-server/cats/src/test/scala/sttp/tapir/server/netty/cats/NettyCatsServerTest.scala index d917ba4dc5..0ce29a8829 100644 --- a/server/netty-server/cats/src/test/scala/sttp/tapir/server/netty/cats/NettyCatsServerTest.scala +++ b/server/netty-server/cats/src/test/scala/sttp/tapir/server/netty/cats/NettyCatsServerTest.scala @@ -4,7 +4,7 @@ import cats.effect.{IO, Resource} import io.netty.channel.nio.NioEventLoopGroup import org.scalatest.EitherValues import sttp.monad.MonadError -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.netty.internal.FutureUtil import sttp.tapir.server.tests._ import sttp.tapir.tests.{Test, TestSuite} diff --git a/server/vertx-server/cats/src/test/scala/sttp/tapir/server/vertx/cats/VertxStubServerTest.scala b/server/vertx-server/cats/src/test/scala/sttp/tapir/server/vertx/cats/VertxStubServerTest.scala index db805052c7..bcea7b30a3 100644 --- a/server/vertx-server/cats/src/test/scala/sttp/tapir/server/vertx/cats/VertxStubServerTest.scala +++ b/server/vertx-server/cats/src/test/scala/sttp/tapir/server/vertx/cats/VertxStubServerTest.scala @@ -5,7 +5,7 @@ import cats.effect.std.Dispatcher import cats.effect.unsafe.implicits.global import sttp.capabilities.fs2.Fs2Streams import sttp.client3.testing.SttpBackendStub -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.interceptor.CustomiseInterceptors import sttp.tapir.server.tests.{CreateServerStubTest, ServerStubStreamingTest, ServerStubTest} diff --git a/serverless/aws/lambda-tests/src/test/scala/sttp/tapir/serverless/aws/lambda/tests/AwsLambdaCreateServerStubTest.scala b/serverless/aws/lambda-tests/src/test/scala/sttp/tapir/serverless/aws/lambda/tests/AwsLambdaCreateServerStubTest.scala index a743eff622..f901fe6188 100644 --- a/serverless/aws/lambda-tests/src/test/scala/sttp/tapir/serverless/aws/lambda/tests/AwsLambdaCreateServerStubTest.scala +++ b/serverless/aws/lambda-tests/src/test/scala/sttp/tapir/serverless/aws/lambda/tests/AwsLambdaCreateServerStubTest.scala @@ -11,7 +11,7 @@ import sttp.client3.testing.SttpBackendStub import sttp.client3.{ByteArrayBody, ByteBufferBody, InputStreamBody, NoBody, Request, Response, StringBody, SttpBackend, _} import sttp.model.{Header, StatusCode, Uri} import sttp.tapir.PublicEndpoint -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.server.ServerEndpoint import sttp.tapir.server.tests.CreateServerTest import sttp.tapir.serverless.aws.lambda._ diff --git a/serverless/aws/lambda/src/main/scala/sttp/tapir/serverless/aws/lambda/runtime/AwsLambdaRuntimeInvocation.scala b/serverless/aws/lambda/src/main/scala/sttp/tapir/serverless/aws/lambda/runtime/AwsLambdaRuntimeInvocation.scala index e9db9d5333..0919cc62c9 100644 --- a/serverless/aws/lambda/src/main/scala/sttp/tapir/serverless/aws/lambda/runtime/AwsLambdaRuntimeInvocation.scala +++ b/serverless/aws/lambda/src/main/scala/sttp/tapir/serverless/aws/lambda/runtime/AwsLambdaRuntimeInvocation.scala @@ -10,7 +10,7 @@ import io.circe.syntax._ import sttp.client3._ import sttp.monad.MonadError import sttp.monad.syntax._ -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.serverless.aws.lambda.{AwsRequest, AwsResponse, Route} import scala.concurrent.duration.DurationInt diff --git a/serverless/aws/lambda/src/test/scalajvm/sttp/tapir/serverless/aws/lambda/runtime/AwsLambdaRuntimeInvocationTest.scala b/serverless/aws/lambda/src/test/scalajvm/sttp/tapir/serverless/aws/lambda/runtime/AwsLambdaRuntimeInvocationTest.scala index c657771366..dac2d0978d 100644 --- a/serverless/aws/lambda/src/test/scalajvm/sttp/tapir/serverless/aws/lambda/runtime/AwsLambdaRuntimeInvocationTest.scala +++ b/serverless/aws/lambda/src/test/scalajvm/sttp/tapir/serverless/aws/lambda/runtime/AwsLambdaRuntimeInvocationTest.scala @@ -9,7 +9,7 @@ import sttp.client3._ import sttp.client3.testing.SttpBackendStub import sttp.model.{Header, StatusCode} import sttp.tapir._ -import sttp.tapir.integ.cats.CatsMonadError +import sttp.tapir.integ.cats.effect.CatsMonadError import sttp.tapir.serverless.aws.lambda.runtime.AwsLambdaRuntimeInvocationTest._ import sttp.tapir.serverless.aws.lambda.{AwsCatsEffectServerInterpreter, AwsCatsEffectServerOptions, AwsServerOptions} From e0966298829fab66f26f39211131db175849a676 Mon Sep 17 00:00:00 2001 From: David van Geest Date: Thu, 6 Apr 2023 15:24:23 -0400 Subject: [PATCH 2/4] Fix tests. --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 9dc3c14d51..5a1fe15c21 100644 --- a/build.sbt +++ b/build.sbt @@ -1359,7 +1359,7 @@ lazy val vertxServerCats: ProjectMatrix = (projectMatrix in file("server/vertx-s ) ) .jvmPlatform(scalaVersions = scala2And3Versions) - .dependsOn(serverCore, vertxServer % CompileAndTest, serverTests % Test) + .dependsOn(serverCore, vertxServer % CompileAndTest, serverTests % Test, catsEffect % Test) lazy val vertxServerZio: ProjectMatrix = (projectMatrix in file("server/vertx-server/zio")) .settings(commonJvmSettings) From 6aeee9e7f9c04cc09f87106a4ef873102e3799db Mon Sep 17 00:00:00 2001 From: adamw Date: Thu, 27 Apr 2023 13:43:47 +0200 Subject: [PATCH 3/4] Add catsEffect to aggregates --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index fa4f088516..158ce628d2 100644 --- a/build.sbt +++ b/build.sbt @@ -153,6 +153,7 @@ lazy val loggerDependencies = Seq( lazy val rawAllAggregates = core.projectRefs ++ testing.projectRefs ++ cats.projectRefs ++ + catsEffect.projectRefs ++ enumeratum.projectRefs ++ refined.projectRefs ++ zio1.projectRefs ++ From 2b7bfcec9d2f6f2b8602323abe2badaaded89e56 Mon Sep 17 00:00:00 2001 From: adamw Date: Thu, 27 Apr 2023 13:48:06 +0200 Subject: [PATCH 4/4] Docs --- doc/endpoint/integrations.md | 7 +++++++ doc/migrating.md | 1 + doc/stability.md | 23 ++++++++++++----------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/doc/endpoint/integrations.md b/doc/endpoint/integrations.md index c20d2cb038..e8e055c52d 100644 --- a/doc/endpoint/integrations.md +++ b/doc/endpoint/integrations.md @@ -20,6 +20,13 @@ datatypes as well as additional syntax: - `import sttp.tapir.integ.cats.codec._` - brings schema, validator and codec instances - `import sttp.tapir.integ.cats.syntax._` - brings additional syntax for `tapir` types +Additionally, the `tapir-cats-effect` module contains an implementation of the `CatsMonadError` class, providing a bridge +between the sttp-internal `MonadError` and the cats-effect `Sync` typeclass: + +```scala +"com.softwaremill.sttp.tapir" %% "tapir-cats-effect" % "@VERSION@" +``` + ## Refined integration If you use [refined](https://github.com/fthomas/refined), the `tapir-refined` module will provide implicit codecs and diff --git a/doc/migrating.md b/doc/migrating.md index 60a00ce13b..8b50497c36 100644 --- a/doc/migrating.md +++ b/doc/migrating.md @@ -4,6 +4,7 @@ - Static content endpoints from `sttp.tapir.static._` are deprecated in favor of the new `tapir-files` module. New methods are in `sttp.tapir.files._`: `staticFilesGetServerEndpoint`, `staticFilesHeadServerEndpoint`, `staticFilesServerEndpoints`, `staticResourcesGetServerEndpoint`, `staticResourcesHeadServerEndpoint`, `staticResourcesServerEndpoints`, etc. See the [updated documentation](endpoint/static.md). - Respectively, use `sttp.tapir.files.FilesOptions` instead of `sttp.tapir.static.FilesOptions` +- the `cats` integration module has been split into `cats` and `cats-effect`, with the latter containing the `CatsMonadError` class, providing a bridge between the sttp-internal `MonadError` and the cats-effect `Sync` typeclass. If you've been using this directly, you might need to update your dependencies. ## From 0.20 to 1.0 diff --git a/doc/stability.md b/doc/stability.md index 375be027bb..5118a9b46e 100644 --- a/doc/stability.md +++ b/doc/stability.md @@ -55,17 +55,18 @@ The modules are categorised using the following levels: ## Integration modules -| Module | Level | -|------------------|--------------| -| cats | stabilising | -| derevo | stabilising | -| enumeratum | stabilising | -| newtype | stabilising | -| monix-newtype | stabilising | -| refined | stabilising | -| zio | experimental | -| zio1 | stabilising | -| zio-prelude | experimental | +| Module | Level | +|---------------|--------------| +| cats | stabilising | +| cats-effect | stabilising | +| derevo | stabilising | +| enumeratum | stabilising | +| newtype | stabilising | +| monix-newtype | stabilising | +| refined | stabilising | +| zio | experimental | +| zio1 | stabilising | +| zio-prelude | experimental | ## JSON modules