diff --git a/doc/endpoint/integrations.md b/doc/endpoint/integrations.md index 78078db53e..dfcce5a730 100644 --- a/doc/endpoint/integrations.md +++ b/doc/endpoint/integrations.md @@ -2,15 +2,16 @@ ## Cats datatypes integration -The `tapir-cats` module contains schema, validator and codec instances for some [cats](https://typelevel.org/cats/) -datatypes: +The `tapir-cats` module contains additional instances for some [cats](https://typelevel.org/cats/) +datatypes as well as additional syntax: ```scala "com.softwaremill.sttp.tapir" %% "tapir-cats" % "0.16.5" ``` -See the `sttp.tapir.codec.cats.TapirCodecCats` trait or `import sttp.tapir.codec.cats._` to bring the implicit values -into scope. +- `import sttp.tapir.integ.cats.codec._` - brings schema, validator and codec instances +- `import sttp.tapir.integ.cats.syntax._` - brings additional syntax for `tapir` types + ## Refined integration diff --git a/integrations/cats/src/main/scala/sttp/tapir/cats/syntax.scala b/integrations/cats/src/main/scala/sttp/tapir/cats/syntax.scala deleted file mode 100644 index ff31decbf5..0000000000 --- a/integrations/cats/src/main/scala/sttp/tapir/cats/syntax.scala +++ /dev/null @@ -1,5 +0,0 @@ -package sttp.tapir.cats - -object syntax extends ServerEndpointSyntax - - diff --git a/integrations/cats/src/main/scala/sttp/tapir/codec/cats/package.scala b/integrations/cats/src/main/scala/sttp/tapir/codec/cats/package.scala deleted file mode 100644 index 1be6af7733..0000000000 --- a/integrations/cats/src/main/scala/sttp/tapir/codec/cats/package.scala +++ /dev/null @@ -1,3 +0,0 @@ -package sttp.tapir.codec - -package object cats extends TapirCodecCats diff --git a/integrations/cats/src/main/scala/sttp/tapir/monad/cats/MonadErrorSyntax.scala b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/MonadErrorSyntax.scala similarity index 90% rename from integrations/cats/src/main/scala/sttp/tapir/monad/cats/MonadErrorSyntax.scala rename to integrations/cats/src/main/scala/sttp/tapir/integ/cats/MonadErrorSyntax.scala index 20cebf0698..3db06622fc 100644 --- a/integrations/cats/src/main/scala/sttp/tapir/monad/cats/MonadErrorSyntax.scala +++ b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/MonadErrorSyntax.scala @@ -1,4 +1,4 @@ -package sttp.tapir.monad.cats +package sttp.tapir.integ.cats import cats.~> import sttp.tapir.monad.MonadError @@ -21,3 +21,5 @@ trait MonadErrorSyntax { } } } + +object MonadErrorSyntax extends MonadErrorSyntax diff --git a/integrations/cats/src/main/scala/sttp/tapir/cats/ServerEndpointSyntax.scala b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/ServerEndpointSyntax.scala similarity index 84% rename from integrations/cats/src/main/scala/sttp/tapir/cats/ServerEndpointSyntax.scala rename to integrations/cats/src/main/scala/sttp/tapir/integ/cats/ServerEndpointSyntax.scala index 93f2c03ca6..f721c1f124 100644 --- a/integrations/cats/src/main/scala/sttp/tapir/cats/ServerEndpointSyntax.scala +++ b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/ServerEndpointSyntax.scala @@ -1,4 +1,4 @@ -package sttp.tapir.cats +package sttp.tapir.integ.cats import cats.~> import sttp.tapir.server.ServerEndpoint @@ -6,7 +6,7 @@ import sttp.tapir.server.ServerEndpoint trait ServerEndpointSyntax { implicit class ServerEndpointImapK[I, E, O, S, F[_]](endpoint: ServerEndpoint[I, E, O, S, F]) { - import sttp.tapir.monad.cats.syntax._ + import MonadErrorSyntax._ def imapK[G[_]](fk: F ~> G)(gK: G ~> F): ServerEndpoint[I, E, O, S, G] = endpoint.copy(logic = monadError => i => fk(endpoint.logic(monadError.imapK(gK)(fk))(i))) diff --git a/integrations/cats/src/main/scala/sttp/tapir/codec/cats/TapirCodecCats.scala b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/TapirCodecCats.scala similarity index 96% rename from integrations/cats/src/main/scala/sttp/tapir/codec/cats/TapirCodecCats.scala rename to integrations/cats/src/main/scala/sttp/tapir/integ/cats/TapirCodecCats.scala index d078dce8c8..b9918444be 100644 --- a/integrations/cats/src/main/scala/sttp/tapir/codec/cats/TapirCodecCats.scala +++ b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/TapirCodecCats.scala @@ -1,7 +1,6 @@ -package sttp.tapir.codec.cats +package sttp.tapir.integ.cats import cats.data.{NonEmptyChain, NonEmptyList, NonEmptySet} -import sttp.tapir.{Schema, SchemaType} import sttp.tapir._ import scala.collection.immutable.SortedSet diff --git a/integrations/cats/src/main/scala/sttp/tapir/integ/cats/codec.scala b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/codec.scala new file mode 100644 index 0000000000..e5a78c345c --- /dev/null +++ b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/codec.scala @@ -0,0 +1,3 @@ +package sttp.tapir.integ.cats + +object codec extends TapirCodecCats diff --git a/integrations/cats/src/main/scala/sttp/tapir/integ/cats/syntax.scala b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/syntax.scala new file mode 100644 index 0000000000..2db9263284 --- /dev/null +++ b/integrations/cats/src/main/scala/sttp/tapir/integ/cats/syntax.scala @@ -0,0 +1,5 @@ +package sttp.tapir.integ.cats + +object syntax extends ServerEndpointSyntax with MonadErrorSyntax + + diff --git a/integrations/cats/src/main/scala/sttp/tapir/monad/cats/syntax.scala b/integrations/cats/src/main/scala/sttp/tapir/monad/cats/syntax.scala deleted file mode 100644 index e7835a7f17..0000000000 --- a/integrations/cats/src/main/scala/sttp/tapir/monad/cats/syntax.scala +++ /dev/null @@ -1,3 +0,0 @@ -package sttp.tapir.monad.cats - -object syntax extends MonadErrorSyntax diff --git a/integrations/cats/src/test/scala/sttp/tapir/codec/cats/TapirCodecCatsTest.scala b/integrations/cats/src/test/scala/sttp/tapir/integ/cats/TapirCodecCatsTest.scala similarity index 99% rename from integrations/cats/src/test/scala/sttp/tapir/codec/cats/TapirCodecCatsTest.scala rename to integrations/cats/src/test/scala/sttp/tapir/integ/cats/TapirCodecCatsTest.scala index 9ca913d644..a7e47299b5 100644 --- a/integrations/cats/src/test/scala/sttp/tapir/codec/cats/TapirCodecCatsTest.scala +++ b/integrations/cats/src/test/scala/sttp/tapir/integ/cats/TapirCodecCatsTest.scala @@ -1,4 +1,4 @@ -package sttp.tapir.codec.cats +package sttp.tapir.integ.cats import cats.data.{NonEmptyChain, NonEmptyList, NonEmptySet} import org.scalacheck.{Arbitrary, Gen} @@ -8,6 +8,7 @@ import org.scalacheck.Arbitrary.arbString import sttp.tapir.SchemaType.{SArray, SString} import sttp.tapir.{Codec, CodecFormat, DecodeResult, Schema, Validator} import sttp.tapir.internal._ +import codec._ import scala.collection.immutable.SortedSet