Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract tapir-cats-effect module from tapir-cats #2823

Merged
merged 6 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ lazy val loggerDependencies = Seq(
lazy val rawAllAggregates = core.projectRefs ++
testing.projectRefs ++
cats.projectRefs ++
catsEffect.projectRefs ++
enumeratum.projectRefs ++
refined.projectRefs ++
zio1.projectRefs ++
Expand Down Expand Up @@ -525,8 +526,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,
Expand Down Expand Up @@ -562,6 +562,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(
Expand Down Expand Up @@ -1159,7 +1181,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"))
Expand Down Expand Up @@ -1206,7 +1228,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)
Expand Down Expand Up @@ -1288,7 +1310,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)
Expand Down Expand Up @@ -1317,7 +1339,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)
Expand Down Expand Up @@ -1359,7 +1381,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)
Expand Down Expand Up @@ -1415,7 +1437,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
Expand Down
7 changes: 7 additions & 0 deletions doc/endpoint/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 12 additions & 11 deletions doc/stability.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sttp.tapir.integ.cats
package sttp.tapir.integ.cats.effect

import cats.effect.Sync
import sttp.monad.MonadError
Expand Down
1 change: 1 addition & 0 deletions project/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.9"
val circe = "0.14.3"
val circeGenericExtras = "0.14.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down