diff --git a/README.md b/README.md index aa67dbd4ef..cd4534bb15 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ tapir documentation is available at [tapir.softwaremill.com](http://tapir.softwa Add the following dependency: ```sbt -"com.softwaremill.sttp.tapir" %% "tapir-core" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-core" % "0.20.0-M9" ``` Partial unification is now enabled by default from Scala 2.13. However, if you're using Scala 2.12 or older, then diff --git a/doc/docs/openapi.md b/doc/docs/openapi.md index 0761305046..a354308a3c 100644 --- a/doc/docs/openapi.md +++ b/doc/docs/openapi.md @@ -7,7 +7,7 @@ To generate OpenAPI documentation and expose it using the Swagger UI in a single step, first add the dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % "0.20.0-M9" ``` Then, you can interpret a list of endpoints, as server endpoints exposing the Swagger UI, using `SwaggerInterpreter`. @@ -46,7 +46,7 @@ for details. Similarly as above, you'll need the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-redoc-bundle" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-redoc-bundle" % "0.20.0-M9" ``` And the server endpoints can be generated using the `sttp.tapir.redoc.bundle.RedocInterpreter` class. diff --git a/generated-doc/out/client/http4s.md b/generated-doc/out/client/http4s.md index 47dc8c4041..2ee986cc20 100644 --- a/generated-doc/out/client/http4s.md +++ b/generated-doc/out/client/http4s.md @@ -3,7 +3,7 @@ Add the dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-http4s-client" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-http4s-client" % "0.20.0-M9" ``` To interpret an endpoint definition as an `org.http4s.Request[F]`, import: diff --git a/generated-doc/out/client/play.md b/generated-doc/out/client/play.md index e27cbed604..209c98b2b2 100644 --- a/generated-doc/out/client/play.md +++ b/generated-doc/out/client/play.md @@ -3,7 +3,7 @@ Add the dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-play-client" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-play-client" % "0.20.0-M9" ``` To make requests using an endpoint definition using the [play client](https://github.com/playframework/play-ws), import: diff --git a/generated-doc/out/client/sttp.md b/generated-doc/out/client/sttp.md index 4b6d465253..20a1a6e1aa 100644 --- a/generated-doc/out/client/sttp.md +++ b/generated-doc/out/client/sttp.md @@ -3,7 +3,7 @@ Add the dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-sttp-client" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-sttp-client" % "0.20.0-M9" ``` To make requests using an endpoint definition using the [sttp client](https://github.com/softwaremill/sttp), import: @@ -66,13 +66,15 @@ convert sttp's `WebSocket` instance into a pipe. This logic is looked up via the The required imports are as follows: ```scala -import sttp.tapir.client.sttp.ws.akkahttp._ // for akka-streams // for akka-streams -import sttp.tapir.client.sttp.ws.fs2._ // for fs2 // for fs2 -import sttp.tapir.client.sttp.ws.zio._ // for zio +import sttp.tapir.client.sttp.ws.akkahttp._ // for akka-streams +import sttp.tapir.client.sttp.ws.fs2._ // for fs2 +import sttp.tapir.client.sttp.ws.zio._ // for zio 2.x +import sttp.tapir.client.sttp.ws.zio1._ // for zio 1.x ``` -No additional dependencies are needed, as both of the above implementations are included in the main interpreter, -with dependencies on akka-streams, fs2 and zio being marked as optional (hence these are not transitive). +No additional dependencies are needed (except for zio1, which needs the `tapir-sttp-client-ws-zio1` dependency), as +both of the above implementations are included in the main interpreter, with dependencies on akka-streams, fs2 and zio +being marked as optional (hence these are not transitive). ## Scala.JS @@ -80,7 +82,7 @@ In this case add the following dependencies (note the [`%%%`](https://www.scala- instead of the usual `%%`): ```scala -"com.softwaremill.sttp.tapir" %%% "tapir-sttp-client" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %%% "tapir-sttp-client" % "0.20.0-M9" "io.github.cquiroz" %%% "scala-java-time" % "2.2.0" // implementations of java.time classes for Scala.JS ``` diff --git a/generated-doc/out/docs/asyncapi.md b/generated-doc/out/docs/asyncapi.md index 09e7191587..43c7c77b3a 100644 --- a/generated-doc/out/docs/asyncapi.md +++ b/generated-doc/out/docs/asyncapi.md @@ -3,8 +3,8 @@ To use, add the following dependencies: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-asyncapi-docs" % "0.20.0-M8" -"com.softwaremill.sttp.tapir" %% "tapir-asyncapi-circe-yaml" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-asyncapi-docs" % "0.20.0-M9" +"com.softwaremill.sttp.tapir" %% "tapir-asyncapi-circe-yaml" % "0.20.0-M9" ``` Tapir contains a case class-based model of the asyncapi data structures in the `asyncapi/asyncapi-model` subproject (the diff --git a/generated-doc/out/docs/openapi.md b/generated-doc/out/docs/openapi.md index 5da0279d9b..73ee9f7e19 100644 --- a/generated-doc/out/docs/openapi.md +++ b/generated-doc/out/docs/openapi.md @@ -7,7 +7,7 @@ To generate OpenAPI documentation and expose it using the Swagger UI in a single step, first add the dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % "0.20.0-M9" ``` Then, you can interpret a list of endpoints, as server endpoints exposing the Swagger UI, using `SwaggerInterpreter`. @@ -38,12 +38,15 @@ Moreover, model generation can be configured - see below for more details on `Op parameters of `fromEndpoitns`. Finally, the generated model can be customised. See the scaladocs for `SwaggerInterpreter`. +The swagger server endpoints can be secured using `ServerLogic.prependSecurity`, see [server logic](../server/logic.md) +for details. + ### Using Redoc Similarly as above, you'll need the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-redoc-bundle" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-redoc-bundle" % "0.20.0-M9" ``` And the server endpoints can be generated using the `sttp.tapir.redoc.bundle.RedocInterpreter` class. @@ -53,8 +56,8 @@ And the server endpoints can be generated using the `sttp.tapir.redoc.bundle.Red To generate the docs in the OpenAPI yaml format, add the following dependencies: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-openapi-docs" % "0.20.0-M8" -"com.softwaremill.sttp.tapir" %% "tapir-openapi-circe-yaml" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-openapi-docs" % "0.20.0-M9" +"com.softwaremill.sttp.tapir" %% "tapir-openapi-circe-yaml" % "0.20.0-M9" ``` Tapir contains a case class-based model of the openapi data structures in the `openapi/openapi-model` subproject (the @@ -190,12 +193,12 @@ The modules `tapir-swagger-ui` and `tapir-redoc` contain server endpoint definit yaml format, will expose it using the given context path. To use, add as a dependency either `tapir-swagger-ui`: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui" % "0.20.0-M9" ``` or `tapir-redoc`: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-redoc" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-redoc" % "0.20.0-M9" ``` Then, you'll need to pass the server endpoints to your server interpreter. For example, using akka-http: diff --git a/generated-doc/out/endpoint/integrations.md b/generated-doc/out/endpoint/integrations.md index 84bbd32d54..870392b7d9 100644 --- a/generated-doc/out/endpoint/integrations.md +++ b/generated-doc/out/endpoint/integrations.md @@ -6,7 +6,7 @@ The `tapir-cats` module contains additional instances for some [cats](https://ty datatypes as well as additional syntax: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-cats" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-cats" % "0.20.0-M9" ``` - `import sttp.tapir.integ.cats.codec._` - brings schema, validator and codec instances @@ -18,7 +18,7 @@ If you use [refined](https://github.com/fthomas/refined), the `tapir-refined` mo validators for `T Refined P` as long as a codec for `T` already exists: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-refined" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-refined" % "0.20.0-M9" ``` You'll need to extend the `sttp.tapir.codec.refined.TapirCodecRefined` @@ -39,7 +39,7 @@ The `tapir-enumeratum` module provides schemas, validators and codecs for [Enume enumerations. To use, add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-enumeratum" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-enumeratum" % "0.20.0-M9" ``` Then, `import sttp.tapir.codec.enumeratum`, or extends the `sttp.tapir.codec.enumeratum.TapirCodecEnumeratum` trait. @@ -77,7 +77,7 @@ If you use [scala-newtype](https://github.com/estatico/scala-newtype), the `tapi schemas for a types with a `@newtype` and `@newsubtype` annotations as long as a codec and schema for its underlying value already exists: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-newtype" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-newtype" % "0.20.0-M9" ``` Then, `import sttp.tapir.codec.newtype._`, or extend the `sttp.tapir.codec.enumeratum.TapirCodecNewType` trait to bring the implicit values into scope. @@ -89,7 +89,7 @@ For details refer to [derevo documentation](https://github.com/tofu-tf/derevo#in To use, add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-derevo" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-derevo" % "0.20.0-M9" ``` Then you can derive schema for your ADT along with other typeclasses besides ADT declaration itself: diff --git a/generated-doc/out/endpoint/json.md b/generated-doc/out/endpoint/json.md index 06ac586446..f828900c0b 100644 --- a/generated-doc/out/endpoint/json.md +++ b/generated-doc/out/endpoint/json.md @@ -17,7 +17,7 @@ the json codec that is in scope. To use Circe, add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % "0.20.0-M9" ``` Next, import the package (or extend the `TapirJsonCirce` trait, see [MyTapir](../mytapir.md)): @@ -91,7 +91,7 @@ Now the above JSON object will render as To use µPickle add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-upickle" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-json-upickle" % "0.20.0-M9" ``` Next, import the package (or extend the `TapirJsonuPickle` trait, see [MyTapir](../mytapir.md) and add `TapirJsonuPickle` not `TapirCirceJson`): @@ -126,7 +126,7 @@ For more examples, including making a custom encoder/decoder, see [TapirJsonuPic To use Play JSON add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-play" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-json-play" % "0.20.0-M9" ``` Next, import the package (or extend the `TapirJsonPlay` trait, see [MyTapir](../mytapir.md) and add `TapirJsonPlay` not `TapirCirceJson`): @@ -142,7 +142,7 @@ Play JSON requires `Reads` and `Writes` implicit values in scope for each type y To use Spray JSON add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-spray" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-json-spray" % "0.20.0-M9" ``` Next, import the package (or extend the `TapirJsonSpray` trait, see [MyTapir](../mytapir.md) and add `TapirJsonSpray` not `TapirCirceJson`): @@ -158,7 +158,7 @@ Spray JSON requires a `JsonFormat` implicit value in scope for each type you wan To use Tethys JSON add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-tethys" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-json-tethys" % "0.20.0-M9" ``` Next, import the package (or extend the `TapirJsonTethys` trait, see [MyTapir](../mytapir.md) and add `TapirJsonTethys` not `TapirCirceJson`): @@ -174,7 +174,7 @@ Tethys JSON requires `JsonReader` and `JsonWriter` implicit values in scope for To use [Jsoniter-scala](https://github.com/plokhotnyuk/jsoniter-scala) add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-jsoniter-scala" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-jsoniter-scala" % "0.20.0-M9" ``` Next, import the package (or extend the `TapirJsonJsoniter` trait, see [MyTapir](../mytapir.md) and add `TapirJsonJsoniter` not `TapirCirceJson`): @@ -191,7 +191,7 @@ Jsoniter Scala requires `JsonValueCodec` implicit value in scope for each type y To use [json4s](https://github.com/json4s/json4s) add the following dependencies to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-json4s" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-json-json4s" % "0.20.0-M9" ``` And one of the implementations: @@ -222,7 +222,7 @@ implicit val formats: Formats = org.json4s.jackson.Serialization.formats(NoTypeH To use Zio JSON, add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-zio" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-json-zio" % "0.20.0-M9" ``` Next, import the package (or extend the `TapirJsonZio` trait, see [MyTapir](../mytapir.md) and add `TapirJsonZio` instead of `TapirCirceJson`): diff --git a/generated-doc/out/endpoint/static.md b/generated-doc/out/endpoint/static.md index 0bf914d087..af8641c758 100644 --- a/generated-doc/out/endpoint/static.md +++ b/generated-doc/out/endpoint/static.md @@ -29,6 +29,9 @@ Using the above endpoint, a request to `/site/static/css/styles.css` will try to A single file can be exposed using `fileGetServerEndpoint`. +The file server endpoints can be secured using `ServerLogic.prependSecurity`, see [server logic](../server/logic.md) +for details. + ## Resources Similarly, the `resourcesGetServerEndpoint` can be used to expose the application's resources at the given prefix. diff --git a/generated-doc/out/examples.md b/generated-doc/out/examples.md index 7f3b53192b..9bfa044df4 100644 --- a/generated-doc/out/examples.md +++ b/generated-doc/out/examples.md @@ -1,6 +1,6 @@ # Examples -The [`examples`](https://github.com/softwaremill/tapir/tree/master/examples/src/main/scala/sttp/tapir/examples) sub-project contains a number of runnable tapir usage examples, using various interpreters and showcasing different features. +The [`examples`](https://github.com/softwaremill/tapir/tree/master/examples/src/main/scala/sttp/tapir/examples) and [`examples3`](https://github.com/softwaremill/tapir/tree/master/examples/src/main/scala/sttp/tapir/examples3) sub-projects (the latter containing Scala 3-only code) contains a number of runnable tapir usage examples, using various interpreters and showcasing different features. ## Other examples diff --git a/generated-doc/out/generator/sbt-openapi-codegen.md b/generated-doc/out/generator/sbt-openapi-codegen.md index 60e46d3925..611fed0b4f 100644 --- a/generated-doc/out/generator/sbt-openapi-codegen.md +++ b/generated-doc/out/generator/sbt-openapi-codegen.md @@ -11,7 +11,7 @@ Add the sbt plugin to the `project/plugins.sbt`: ```scala -addSbtPlugin("com.softwaremill.sttp.tapir" % "sbt-openapi-codegen" % "0.20.0-M8") +addSbtPlugin("com.softwaremill.sttp.tapir" % "sbt-openapi-codegen" % "0.20.0-M9") ``` Enable the plugin for your project in the `build.sbt`: diff --git a/generated-doc/out/quickstart.md b/generated-doc/out/quickstart.md index 41581a038e..d464eb4dcb 100644 --- a/generated-doc/out/quickstart.md +++ b/generated-doc/out/quickstart.md @@ -3,7 +3,7 @@ To use tapir, add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-core" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-core" % "0.20.0-M9" ``` This will import only the core classes needed to create endpoint descriptions. To generate a server or a client, you diff --git a/generated-doc/out/server/akkahttp.md b/generated-doc/out/server/akkahttp.md index c874302af0..89ca42b5a0 100644 --- a/generated-doc/out/server/akkahttp.md +++ b/generated-doc/out/server/akkahttp.md @@ -4,14 +4,14 @@ To expose an endpoint as an [akka-http](https://doc.akka.io/docs/akka-http/curre dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-akka-http-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-akka-http-server" % "0.20.0-M9" ``` This will transitively pull some Akka modules in version 2.6. If you want to force your own Akka version (for example 2.5), use sbt exclusion. Mind the Scala version in artifact name: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-akka-http-server" % "0.20.0-M8" exclude("com.typesafe.akka", "akka-stream_2.12") +"com.softwaremill.sttp.tapir" %% "tapir-akka-http-server" % "0.20.0-M9" exclude("com.typesafe.akka", "akka-stream_2.12") ``` Now import the object: diff --git a/generated-doc/out/server/aws.md b/generated-doc/out/server/aws.md index ba91dd8a3c..cf250fe6ea 100644 --- a/generated-doc/out/server/aws.md +++ b/generated-doc/out/server/aws.md @@ -13,7 +13,7 @@ To implement the Lambda function, a server interpreter is available, which takes Currently, only an interpreter integrating with cats-effect is available (`AwsCatsEffectServerInterpreter`). To use, add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-aws-lambda" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-aws-lambda" % "0.20.0-M9" ``` To configure API Gateway and the Lambda function, you can use: @@ -24,8 +24,8 @@ To configure API Gateway and the Lambda function, you can use: Add one of the following dependencies: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-aws-sam" % "0.20.0-M8" -"com.softwaremill.sttp.tapir" %% "tapir-aws-terraform" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-aws-sam" % "0.20.0-M9" +"com.softwaremill.sttp.tapir" %% "tapir-aws-terraform" % "0.20.0-M9" ``` ## Examples diff --git a/generated-doc/out/server/finatra.md b/generated-doc/out/server/finatra.md index a819fa3974..7b1de27af8 100644 --- a/generated-doc/out/server/finatra.md +++ b/generated-doc/out/server/finatra.md @@ -4,7 +4,7 @@ To expose an endpoint as an [finatra](https://twitter.github.io/finatra/) server dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-finatra-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-finatra-server" % "0.20.0-M9" ``` and import the object: @@ -17,7 +17,7 @@ This interpreter supports the twitter `Future`. Or, if you would like to use cats-effect project, you can add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-finatra-server-cats" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-finatra-server-cats" % "0.20.0-M9" ``` and import the object: diff --git a/generated-doc/out/server/http4s.md b/generated-doc/out/server/http4s.md index 4b905444de..eeed0336b9 100644 --- a/generated-doc/out/server/http4s.md +++ b/generated-doc/out/server/http4s.md @@ -4,7 +4,7 @@ To expose an endpoint as an [http4s](https://http4s.org) server, first add the f dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-http4s-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-http4s-server" % "0.20.0-M9" ``` and import the object: diff --git a/generated-doc/out/server/logic.md b/generated-doc/out/server/logic.md index 8b709ec0f8..625f4a8135 100644 --- a/generated-doc/out/server/logic.md +++ b/generated-doc/out/server/logic.md @@ -135,7 +135,7 @@ import scala.concurrent.Future implicit val ec = scala.concurrent.ExecutionContext.global case class User(name: String) -def auth(token: String): Future[Either[Int, User]] = Future { +def authLogic(token: String): Future[Either[Int, User]] = Future { if (token == "secret") Right(User("Spock")) else Left(1001) // error code } @@ -144,7 +144,7 @@ val secureEndpoint: PartialServerEndpoint[String, User, Unit, Int, Unit, Any, Fu endpoint .securityIn(header[String]("X-AUTH-TOKEN")) .errorOut(plainBody[Int]) - .serverSecurityLogic(auth) + .serverSecurityLogic(authLogic) ``` The result is a value of type `PartialServerEndpoint`, which can be extended with further inputs and outputs, just @@ -169,3 +169,25 @@ val secureHelloWorld1WithLogic: ServerEndpoint[Any, Future] = secureEndpoint.get By default, successful responses are returned with the `200 OK` status code, and errors with `400 Bad Request`. However, this can be customised by using a [status code output](../endpoint/ios.md). + +## Additional security logic + +In some cases, e.g. when using some pre-defined public server endpoints, such as ones for [serving static content](../endpoint/static.md) +or to expose the [Swagger UI](../docs/openapi.md), it might be necessary to add a security check. One way to achieve +this is extending the pre-defined endpoint description with security inputs, and then re-using the appropriate server +logic, with custom security logic, but this requires non-trivial amount of code. + +For such situations, a `ServerLogic.prependSecurity` method is provided. It accepts a security input description, along +with an error output (for security errors) and the security logic to add. This additional security logic is run +before the security logic defined in the endpoint so far (if any). For example: + +```scala +import sttp.tapir._ +import scala.concurrent.Future +import sttp.model.StatusCode + +val secureFileEndpoints = filesServerEndpoints[Future]("secure")("/home/data") + .map(_.prependSecurity(auth.bearer[String](), statusCode(StatusCode.Forbidden)) { token => + Future.successful(if (token.startsWith("secret")) Right(()) else Left(())) + }) +``` \ No newline at end of file diff --git a/generated-doc/out/server/netty.md b/generated-doc/out/server/netty.md index 19a0a70bff..fa4205e27d 100644 --- a/generated-doc/out/server/netty.md +++ b/generated-doc/out/server/netty.md @@ -5,7 +5,7 @@ To expose an endpoint using a [Netty](https://netty.io)-based server, first add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-netty-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-netty-server" % "0.20.0-M9" ``` Then, use: diff --git a/generated-doc/out/server/observability.md b/generated-doc/out/server/observability.md index 57743eaee0..0398bc7126 100644 --- a/generated-doc/out/server/observability.md +++ b/generated-doc/out/server/observability.md @@ -49,7 +49,7 @@ val labels = MetricLabels( Add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-prometheus-metrics" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-prometheus-metrics" % "0.20.0-M9" ``` `PrometheusMetrics` encapsulates `CollectorReqistry` and `Metric` instances. It provides several ready to use metrics as @@ -124,7 +124,7 @@ val prometheusMetrics = PrometheusMetrics[Future]("tapir", CollectorRegistry.def Add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-opentelemetry-metrics" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-opentelemetry-metrics" % "0.20.0-M9" ``` OpenTelemetry metrics are vendor-agnostic and can be exported using one diff --git a/generated-doc/out/server/play.md b/generated-doc/out/server/play.md index 0e259a8024..aa1984846f 100644 --- a/generated-doc/out/server/play.md +++ b/generated-doc/out/server/play.md @@ -3,7 +3,7 @@ To expose endpoint as a [play-server](https://www.playframework.com/) first add the following dependencies: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-play-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-play-server" % "0.20.0-M9" ``` and (if you don't already depend on Play) diff --git a/generated-doc/out/server/vertx.md b/generated-doc/out/server/vertx.md index 4fd13e38fd..2bce191208 100644 --- a/generated-doc/out/server/vertx.md +++ b/generated-doc/out/server/vertx.md @@ -8,7 +8,7 @@ Vert.x interpreter can be used with different effect systems (cats-effect, ZIO) Add the following dependency ```scala -"com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % "0.20.0-M9" ``` to use this interpreter with `Future`. @@ -63,7 +63,7 @@ It's also possible to define an endpoint together with the server logic in a sin Add the following dependency ```scala -"com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % "0.20.0-M9" "com.softwaremill.sttp.shared" %% "fs2" % "LatestVersion" ``` to use this interpreter with Cats Effect typeclasses. @@ -146,7 +146,7 @@ val attach = VertxCatsServerInterpreter(dispatcher).route(streamedResponse.serve Add the following dependency ```scala -"com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % "0.20.0-M9" "com.softwaremill.sttp.shared" %% "zio" % "LatestVersion" ``` diff --git a/generated-doc/out/server/zio-http4s.md b/generated-doc/out/server/zio-http4s.md index b3979d7e8c..6a54d155be 100644 --- a/generated-doc/out/server/zio-http4s.md +++ b/generated-doc/out/server/zio-http4s.md @@ -9,13 +9,13 @@ The `*-zio` modules depend on ZIO 2.x. For ZIO 1.x support, use modules with the You'll need the following dependency for the `ZServerEndpoint` type alias and helper classes: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-zio" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-zio" % "0.20.0-M9" ``` or just add the zio-http4s integration which already depends on `tapir-zio`: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-zio-http4s-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-zio-http4s-server" % "0.20.0-M9" ``` Next, instead of the usual `import sttp.tapir._`, you should import (or extend the `ZTapir` trait, see [MyTapir](../mytapir.md)): diff --git a/generated-doc/out/server/ziohttp.md b/generated-doc/out/server/ziohttp.md index 6be6f51192..4fd11af7e9 100644 --- a/generated-doc/out/server/ziohttp.md +++ b/generated-doc/out/server/ziohttp.md @@ -9,13 +9,13 @@ The `*-zio` modules depend on ZIO 2.x. For ZIO 1.x support, use modules with the You'll need the following dependency for the `ZServerEndpoint` type alias and helper classes: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-zio" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-zio" % "0.20.0-M9" ``` or just add the zio-http integration which already depends on `tapir-zio`: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-zio-http-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-zio-http-server" % "0.20.0-M9" ``` Next, instead of the usual `import sttp.tapir._`, you should import (or extend the `ZTapir` trait, see [MyTapir](../mytapir.md)): diff --git a/generated-doc/out/testing.md b/generated-doc/out/testing.md index 9a38070068..930d7d9800 100644 --- a/generated-doc/out/testing.md +++ b/generated-doc/out/testing.md @@ -12,7 +12,7 @@ details on how the stub works). Add the dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server" % "0.20.0-M9" ``` And the following imports: @@ -79,7 +79,7 @@ with [mock-server](https://www.mock-server.com/) Add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-sttp-mock-server" % "0.20.0-M8" +"com.softwaremill.sttp.tapir" %% "tapir-sttp-mock-server" % "0.20.0-M9" ``` Imports: