From 809cb64e1700c824a2f650a6701b811a4a859852 Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 24 Aug 2022 09:32:46 +0200 Subject: [PATCH] Release 1.0.6 --- README.md | 2 +- doc/docs/openapi.md | 4 +- generated-doc/out/client/http4s.md | 2 +- generated-doc/out/client/play.md | 2 +- generated-doc/out/client/sttp.md | 4 +- generated-doc/out/docs/asyncapi.md | 2 +- generated-doc/out/docs/openapi.md | 10 +-- generated-doc/out/endpoint/integrations.md | 10 +-- generated-doc/out/endpoint/ios.md | 2 +- generated-doc/out/endpoint/json.md | 35 ++++++-- generated-doc/out/endpoint/schemas.md | 6 ++ generated-doc/out/endpoint/validation.md | 85 +++++++++++++------ .../out/generator/sbt-openapi-codegen.md | 2 +- generated-doc/out/quickstart.md | 2 +- generated-doc/out/server/akkahttp.md | 4 +- generated-doc/out/server/armeria.md | 8 +- generated-doc/out/server/aws.md | 6 +- generated-doc/out/server/finatra.md | 4 +- generated-doc/out/server/http4s.md | 2 +- generated-doc/out/server/interceptors.md | 3 + generated-doc/out/server/netty.md | 4 +- generated-doc/out/server/observability.md | 6 +- generated-doc/out/server/play.md | 2 +- generated-doc/out/server/vertx.md | 8 +- generated-doc/out/server/zio-http4s.md | 6 +- generated-doc/out/server/ziohttp.md | 4 +- generated-doc/out/testing.md | 8 +- 27 files changed, 145 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index 2239a1bea9..6c15981f85 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ tapir documentation is available at [tapir.softwaremill.com](http://tapir.softwa Add the following dependency: ```sbt -"com.softwaremill.sttp.tapir" %% "tapir-core" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-core" % "1.0.6" ``` Then, import: diff --git a/doc/docs/openapi.md b/doc/docs/openapi.md index 1f6c07dce3..836b10bc20 100644 --- a/doc/docs/openapi.md +++ b/doc/docs/openapi.md @@ -13,7 +13,7 @@ these steps can be done separately, giving you complete control over the process 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % "1.0.6" ``` Then, you can interpret a list of endpoints using `SwaggerInterpreter`. The result will be a list of file-serving @@ -55,7 +55,7 @@ for details. Similarly as above, you'll need the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-redoc-bundle" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-redoc-bundle" % "1.0.6" ``` 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 487c840afb..2442a14965 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-http4s-client" % "1.0.6" ``` 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 bc0b04c894..2fed5e9cb8 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-play-client" % "1.0.6" ``` 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 a8c3751e0e..a63e8f98ee 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-sttp-client" % "1.0.6" ``` To make requests using an endpoint definition using the [sttp client](https://github.com/softwaremill/sttp), import: @@ -102,7 +102,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" % "1.0.5" +"com.softwaremill.sttp.tapir" %%% "tapir-sttp-client" % "1.0.6" "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 41a6baf351..7de91b9eb4 100644 --- a/generated-doc/out/docs/asyncapi.md +++ b/generated-doc/out/docs/asyncapi.md @@ -3,7 +3,7 @@ To use, add the following dependencies: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-asyncapi-docs" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-asyncapi-docs" % "1.0.6" "com.softwaremill.sttp.apispec" %% "asyncapi-circe-yaml" % "..." // see https://github.com/softwaremill/sttp-apispec ``` diff --git a/generated-doc/out/docs/openapi.md b/generated-doc/out/docs/openapi.md index 641fb96f13..1ebb42a75b 100644 --- a/generated-doc/out/docs/openapi.md +++ b/generated-doc/out/docs/openapi.md @@ -13,7 +13,7 @@ these steps can be done separately, giving you complete control over the process 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % "1.0.6" ``` Then, you can interpret a list of endpoints using `SwaggerInterpreter`. The result will be a list of file-serving @@ -55,7 +55,7 @@ for details. Similarly as above, you'll need the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-redoc-bundle" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-redoc-bundle" % "1.0.6" ``` And the server endpoints can be generated using the `sttp.tapir.redoc.bundle.RedocInterpreter` class. @@ -65,7 +65,7 @@ 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-openapi-docs" % "1.0.6" "com.softwaremill.sttp.apispec" %% "openapi-circe-yaml" % "..." // see https://github.com/softwaremill/sttp-apispec ``` @@ -136,12 +136,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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui" % "1.0.6" ``` or `tapir-redoc`: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-redoc" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-redoc" % "1.0.6" ``` 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 e4ab175dc4..971b95b8fd 100644 --- a/generated-doc/out/endpoint/integrations.md +++ b/generated-doc/out/endpoint/integrations.md @@ -14,7 +14,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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-cats" % "1.0.6" ``` - `import sttp.tapir.integ.cats.codec._` - brings schema, validator and codec instances @@ -26,7 +26,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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-refined" % "1.0.6" ``` You'll need to extend the `sttp.tapir.codec.refined.TapirCodecRefined` @@ -47,7 +47,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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-enumeratum" % "1.0.6" ``` Then, `import sttp.tapir.codec.enumeratum._`, or extends the `sttp.tapir.codec.enumeratum.TapirCodecEnumeratum` trait. @@ -87,7 +87,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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-newtype" % "1.0.6" ``` Then, `import sttp.tapir.codec.newtype._`, or extend the `sttp.tapir.codec.enumeratum.TapirCodecNewType` trait to bring the implicit values into scope. @@ -99,7 +99,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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-derevo" % "1.0.6" ``` Then you can derive schema for your ADT along with other typeclasses besides ADT declaration itself: diff --git a/generated-doc/out/endpoint/ios.md b/generated-doc/out/endpoint/ios.md index d3ed2fef37..4815442c05 100644 --- a/generated-doc/out/endpoint/ios.md +++ b/generated-doc/out/endpoint/ios.md @@ -220,7 +220,7 @@ To match only the root path, use an empty string: `endpoint.in("")` will match ` `http://server.com`. To match a path prefix, first define inputs which match the path prefix, and then capture any remaining part using -`paths`, e.g.: `endpoint.in("api" / "download").in(paths)"`. +`paths`, e.g.: `endpoint.in("api" / "download").in(paths)`. ## Status codes diff --git a/generated-doc/out/endpoint/json.md b/generated-doc/out/endpoint/json.md index 189e4d2c2b..4a8a8994cb 100644 --- a/generated-doc/out/endpoint/json.md +++ b/generated-doc/out/endpoint/json.md @@ -25,12 +25,31 @@ If you have a custom, implicit `Codec[String, T, Json]` instance, you should use This description of endpoint input/output, instead of deriving a codec basing on other library-specific implicits, uses the json codec that is in scope. +## JSON as string + +If you'd like to work with JSON bodies in a serialised `String` form, instead of integrating on a higher level using +one of the libraries mentioned below, this is also possible. Note that in this case, the serialising/deserialising +of the body must be part of the [server logic](../server/logic.md). + +The `stringBody` body input/output will work, however by default it uses the `text/plain` content type. This can be +customised, by creating a string-based body with the correct codec format (which is a tapir wrapper for media types): + +```scala +import sttp.tapir._ +stringBodyUtf8AnyFormat(Codec.id(CodecFormat.Json(), Schema.string)) + +// or, providing a schema: +import sttp.tapir.generic.auto._ +case class MyBody(field: Int) +stringBodyUtf8AnyFormat(Codec.id(CodecFormat.Json(), implicitly[Schema[MyBody]].as[String])) +``` + ## Circe To use [Circe](https://github.com/circe/circe), add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % "1.0.6" ``` Next, import the package (or extend the `TapirJsonCirce` trait, see [MyTapir](../mytapir.md)): @@ -103,7 +122,7 @@ Now the above JSON object will render as To use [µPickle](http://www.lihaoyi.com/upickle/) add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-upickle" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-json-upickle" % "1.0.6" ``` Next, import the package (or extend the `TapirJsonuPickle` trait, see [MyTapir](../mytapir.md) and add `TapirJsonuPickle` not `TapirCirceJson`): @@ -138,7 +157,7 @@ For more examples, including making a custom encoder/decoder, see [TapirJsonuPic To use [Play JSON](https://github.com/playframework/play-json) add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-play" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-json-play" % "1.0.6" ``` Next, import the package (or extend the `TapirJsonPlay` trait, see [MyTapir](../mytapir.md) and add `TapirJsonPlay` not `TapirCirceJson`): @@ -154,7 +173,7 @@ Play JSON requires `Reads` and `Writes` implicit values in scope for each type y To use [Spray JSON](https://github.com/spray/spray-json) add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-spray" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-json-spray" % "1.0.6" ``` Next, import the package (or extend the `TapirJsonSpray` trait, see [MyTapir](../mytapir.md) and add `TapirJsonSpray` not `TapirCirceJson`): @@ -170,7 +189,7 @@ Spray JSON requires a `JsonFormat` implicit value in scope for each type you wan To use [Tethys JSON](https://github.com/tethys-json/tethys) add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-tethys" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-json-tethys" % "1.0.6" ``` Next, import the package (or extend the `TapirJsonTethys` trait, see [MyTapir](../mytapir.md) and add `TapirJsonTethys` not `TapirCirceJson`): @@ -186,7 +205,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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-jsoniter-scala" % "1.0.6" ``` Next, import the package (or extend the `TapirJsonJsoniter` trait, see [MyTapir](../mytapir.md) and add `TapirJsonJsoniter` not `TapirCirceJson`): @@ -202,7 +221,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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-json-json4s" % "1.0.6" ``` And one of the implementations: @@ -233,7 +252,7 @@ implicit val formats: Formats = org.json4s.jackson.Serialization.formats(NoTypeH To use [zio-json](https://github.com/zio/zio-json), add the following dependency to your project: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-json-zio" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-json-zio" % "1.0.6" ``` 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/schemas.md b/generated-doc/out/endpoint/schemas.md index 08b2b20f74..8a3245c472 100644 --- a/generated-doc/out/endpoint/schemas.md +++ b/generated-doc/out/endpoint/schemas.md @@ -273,6 +273,12 @@ val e: PublicEndpoint[FruitAmount, Unit, Unit, Nothing] = endpoint.in(jsonBody[FruitAmount]) ``` +## Enumerations + +Currently only schemas for Scala2's `Enumeration#Value` enumerations are automatically derived. For Scala3 `enum`s, +an implicit schema value has to be provided by hand. See the enumeration docs in [validation](validation.md) for +details. + ## Next Read on about [validation](validation.md). diff --git a/generated-doc/out/endpoint/validation.md b/generated-doc/out/endpoint/validation.md index f309b34e94..b40f91679d 100644 --- a/generated-doc/out/endpoint/validation.md +++ b/generated-doc/out/endpoint/validation.md @@ -8,24 +8,21 @@ For some guidelines as to where to perform a specific type of validation, see th logic might be if the property that we are checking is a format error, or a business-level error? The validation capabilities described in this section are intended only for format errors. -## Single type validation +Validation rules added using the built-in validators are translated to [OpenAPI](../docs/openapi.md) documentation. -Validation rules are part of the [`Schema`](codecs.md#schemas) for a given type, and can be added either directly -to the schema, or via the `Codec` or `EndpointInput`/`EndpointOutput`. For example, when defining a codec for a type, -we have the `.validate()` method: - -```scala -import sttp.tapir._ -import sttp.tapir.CodecFormat.TextPlain +## Adding validators to schemas -case class MyId(id: String) +A validator is always part of a `Schema`, which is part of a `Codec`. It can validate either the top-level object, or +some nested component (such as a field value). -implicit val myIdCodec: Codec[String, MyId, TextPlain] = Codec.string - .map(MyId(_))(_.id) - .validate(Validator.pattern("^[A-Z].*").contramap(_.id)) -``` - -Validators can also be added to individual inputs/outputs, in addition to whatever the codec provides: +If you are using automatic or semi-automatic schema derivation, validators for such schemas, and their nested +components, including collections and options, can be added as described in +[schema customisation](schemas.md#customising-derived-schemas). + +## Adding validators to inputs/outputs + +Validators can also be added to individual inputs/outputs. Behind the scenes, this modifies the schema, but it's easier +to add top-level validators this way, rather than modifying the implicit schemas, for example: ```scala import sttp.tapir._ @@ -45,29 +42,44 @@ query[Option[Int]]("item").validateOption(Validator.min(0)) query[List[Int]]("item").validateIterable(Validator.min(0)) // validates each repeated parameter ``` -Validation rules added using the built-in validators are translated to [OpenAPI](../docs/openapi.md) documentation. +## Adding validators to codecs + +Finally, if you are creating a reusable [codec](codecs.md), a validator can be added to it as well: + +```scala +import sttp.tapir._ +import sttp.tapir.CodecFormat.TextPlain -## Validation rules and automatic codec derivation +case class MyId(id: String) -As validators are parts of schemas, they are looked up as part of the implicit `Schema[T]` values. When -[customising schemas](schemas.md), use the `.validate` method on the schema to add a validator. +implicit val myIdCodec: Codec[String, MyId, TextPlain] = Codec.string + .map(MyId(_))(_.id) + .validate(Validator.pattern("^[A-Z].*").contramap(_.id)) +``` ## Decode failures -Codecs support reporting decoding failures, by returning a `DecodeResult` from the `Codec.decode` method. However, this -is meant for input/output values which are in an incorrect low-level format, when parsing a "raw value" fails. In other -words, decoding failures should be reported for format failures, not business validation errors. +The validators are run when a value is being decoded from its low-level representation. This is done using the +`Codec.decode` method, which returns a `DecodeResult`. Such a result can be successful, or a decoding failure. + +Keep in mind, that the validator mechanism described here is meant for input/output values which are in an incorrect +low-level format. Validators and more generally decoding failures should be reported only for format failures. +Business validation errors, which are often contextual, should use the error output instead. To customise error messages that are returned upon validation/decode failures by the server, see [error handling](../server/errors.md). -## Enum validators +## Enumeration validators Validators for enumerations can be created using: -* `Validator.derivedEnumeration`, which takes a type parameter. This should be an abstract, sealed base type, and using a - macro determines the possible values -* `Validator.enumeration`, which takes the list of possible values +* for arbitrary types, using `Validator.enumeration`, which takes the list of possible values +* for `sealed` hierarchies, where all implementations are objects, using `Validator.derivedEnumeration[T]`. + This method is a macro which determines the possible values. +* for Scala3 `enum`s, where all implementation don't have parameters, using `Validator.derivedEnumeration[T]` as above +* for Scala2 `Enumeration#Value`, automatically derived `Schema`s have the validator added (see `Schema.derivedEnumerationValue`) + +### Enumeration values in documentation To properly represent possible values in documentation, the enum validator additionally needs an `encode` method, which converts the enum value to a raw type (typically a string). This can be specified by: @@ -77,6 +89,8 @@ converts the enum value to a raw type (typically a string). This can be specifie * when the values possible values are of a basic type (numbers, strings), the encode function is inferred if not present * by adding the validator directly to a codec using `.validate` (the encode function is then taken from the codec) +### Enumerations in schemas/codecs + To simplify creation of schemas and codec, with a derived enum validator, `Schema.derivedEnumeration` and `Codec.derivedEnumeration` helper methods are available. For example: @@ -100,8 +114,8 @@ implicit def plainCodecForColor: PlainCodec[Color] = { } ``` -If the enum is nested within an object and its values aren't of a "basic" type (numbers, strings), regardless of whether -the codec for that object is defined by hand or derived, we need to specify the encode function by hand: +If the enum values aren't of a "basic" type (numbers, strings), regardless of whether the codec for that object is +defined by hand or derived, we need to specify the encode function by hand: ```scala // providing the enum values by hand @@ -112,6 +126,21 @@ implicit def colorSchema: Schema[Color] = Schema.string.validate( implicit def colorSchema2: Schema[Color] = Schema.derivedEnumeration[Color](encode = Some(_.toString.toLowerCase)) ``` +### Scala3 enums + +Due to technical limitations, automatically derived schemas for `enum`s where all cases are parameterless don't have +the enumeration validator added. Until this limitation is lifted, you'll have to define `implicit` (or equivalently, +`given`) schemas in such cases by hand. These values will be used when deriving schemas containing your enumeration: + +```scala +enum ColorEnum { + case Green extends ColorEnum + case Pink extends ColorEnum +} + +given Schema[ColorEnum] = Schema.derivedEnumeration(encode = Some(v => v)) +``` + ## Next Read on about [content types](contenttype.md). diff --git a/generated-doc/out/generator/sbt-openapi-codegen.md b/generated-doc/out/generator/sbt-openapi-codegen.md index c248ce9553..b1eafa6cfc 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" % "1.0.5") +addSbtPlugin("com.softwaremill.sttp.tapir" % "sbt-openapi-codegen" % "1.0.6") ``` 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 4a8aae83b3..d811525061 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-core" % "1.0.6" ``` 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 19867bf44e..a90b9e1636 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-akka-http-server" % "1.0.6" ``` 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" % "1.0.5" exclude("com.typesafe.akka", "akka-stream_2.12") +"com.softwaremill.sttp.tapir" %% "tapir-akka-http-server" % "1.0.6" exclude("com.typesafe.akka", "akka-stream_2.12") ``` Now import the object: diff --git a/generated-doc/out/server/armeria.md b/generated-doc/out/server/armeria.md index f17d4c413a..fbb48a9f54 100644 --- a/generated-doc/out/server/armeria.md +++ b/generated-doc/out/server/armeria.md @@ -8,7 +8,7 @@ Armeria interpreter can be used with different effect systems (cats-effect, ZIO) Add the following dependency ```scala -"com.softwaremill.sttp.tapir" %% "tapir-armeria-server" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-armeria-server" % "1.0.6" ``` and import the object: @@ -75,7 +75,7 @@ Note that Armeria automatically injects an `ExecutionContext` on top of Armeria' Add the following dependency ```scala -"com.softwaremill.sttp.tapir" %% "tapir-armeria-server-cats" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-armeria-server-cats" % "1.0.6" ``` to use this interpreter with Cats Effect typeclasses. @@ -155,9 +155,9 @@ Add the following dependency ```scala // for zio 2: -"com.softwaremill.sttp.tapir" %% "tapir-armeria-server-zio" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-armeria-server-zio" % "1.0.6" // for zio 1: -"com.softwaremill.sttp.tapir" %% "tapir-armeria-server-zio1" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-armeria-server-zio1" % "1.0.6" ``` to use this interpreter with ZIO. diff --git a/generated-doc/out/server/aws.md b/generated-doc/out/server/aws.md index e1ef279359..894d939ede 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-aws-lambda" % "1.0.6" ``` 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" % "1.0.5" -"com.softwaremill.sttp.tapir" %% "tapir-aws-terraform" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-aws-sam" % "1.0.6" +"com.softwaremill.sttp.tapir" %% "tapir-aws-terraform" % "1.0.6" ``` ## Examples diff --git a/generated-doc/out/server/finatra.md b/generated-doc/out/server/finatra.md index 20f153be6e..a3ba35430d 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-finatra-server" % "1.0.6" ``` 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-finatra-server-cats" % "1.0.6" ``` and import the object: diff --git a/generated-doc/out/server/http4s.md b/generated-doc/out/server/http4s.md index f2e017ca3b..f227c30f63 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-http4s-server" % "1.0.6" ``` and import the object: diff --git a/generated-doc/out/server/interceptors.md b/generated-doc/out/server/interceptors.md index 7fb523bedb..4459a6f232 100644 --- a/generated-doc/out/server/interceptors.md +++ b/generated-doc/out/server/interceptors.md @@ -19,6 +19,9 @@ Request interceptors for two common scenarios can be created using the `RequestI Note, that for most server interpreters, the server endpoints passed to the request interceptor will be pre-filtered using `FilterServerEndpoints`, as a performance optimization (these will be only the endpoints for which the request path might potentially decode successfully). + +To enable, disable or configure an interceptor, you'll need to modify the [server options](options.md), using the +`.customiseInterceptors` method. ## Endpoint interceptors diff --git a/generated-doc/out/server/netty.md b/generated-doc/out/server/netty.md index b608c9dcf0..e58f1efaf6 100644 --- a/generated-doc/out/server/netty.md +++ b/generated-doc/out/server/netty.md @@ -4,10 +4,10 @@ To expose an endpoint using a [Netty](https://netty.io)-based server, first add ```scala // if you are using Future or just exploring -"com.softwaremill.sttp.tapir" %% "tapir-netty-server" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-netty-server" % "1.0.6" // if you are using cats-effect: -"com.softwaremill.sttp.tapir" %% "tapir-netty-server-cats" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-netty-server-cats" % "1.0.6" ``` Then, use: diff --git a/generated-doc/out/server/observability.md b/generated-doc/out/server/observability.md index f954010535..4be5d2e6f6 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-prometheus-metrics" % "1.0.6" ``` `PrometheusMetrics` encapsulates `CollectorReqistry` and `Metric` instances. It provides several ready to use metrics as @@ -130,7 +130,7 @@ val prometheusMetrics = PrometheusMetrics[Future]("tapir", CollectorRegistry.def Add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-opentelemetry-metrics" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-opentelemetry-metrics" % "1.0.6" ``` OpenTelemetry metrics are vendor-agnostic and can be exported using one @@ -157,7 +157,7 @@ val metricsInterceptor = metrics.metricsInterceptor() // add to your server opti Add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-datadog-metrics" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-datadog-metrics" % "1.0.6" ``` Datadog metrics are sent as Datadog custom metrics through diff --git a/generated-doc/out/server/play.md b/generated-doc/out/server/play.md index 2dcaeaab9d..534b35130b 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-play-server" % "1.0.6" ``` 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 40a3867608..670f473235 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % "1.0.6" ``` 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-cats" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-vertx-server-cats" % "1.0.6" ``` to use this interpreter with Cats Effect typeclasses. @@ -146,9 +146,9 @@ Add the following dependency ```scala // for zio2: -"com.softwaremill.sttp.tapir" %% "tapir-vertx-server-zio" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-vertx-server-zio" % "1.0.6" // for zio1: -"com.softwaremill.sttp.tapir" %% "tapir-vertx-server-zio1" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-vertx-server-zio1" % "1.0.6" ``` to use this interpreter with ZIO. diff --git a/generated-doc/out/server/zio-http4s.md b/generated-doc/out/server/zio-http4s.md index d67d24d263..e8b711fd51 100644 --- a/generated-doc/out/server/zio-http4s.md +++ b/generated-doc/out/server/zio-http4s.md @@ -9,16 +9,16 @@ 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-zio" % "1.0.6" ``` or just add the zio-http4s integration which already depends on `tapir-zio`: ```scala // for zio 2: -"com.softwaremill.sttp.tapir" %% "tapir-http4s-server-zio" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-http4s-server-zio" % "1.0.6" // for zio 1: -"com.softwaremill.sttp.tapir" %% "tapir-http4s-server-zio1" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-http4s-server-zio1" % "1.0.6" ``` 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 94fefa2d5a..4b103c707a 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" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-zio" % "1.0.6" ``` or just add the zio-http integration which already depends on `tapir-zio`: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-zio-http-server" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-zio-http-server" % "1.0.6" ``` 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 cff19e01b4..aebc0661ca 100644 --- a/generated-doc/out/testing.md +++ b/generated-doc/out/testing.md @@ -23,7 +23,7 @@ Tapir builds upon the `SttpBackendStub` to enable stubbing using `Endpoint`s or dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server" % "1.0.6" ``` Let's assume you are using the [akka http](server/akkahttp.md) interpreter. Given the following server endpoint: @@ -140,7 +140,7 @@ requests matching an endpoint, you can use the tapir `SttpBackendStub` extension Similarly as when testing server interpreters, add the dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server" % "1.0.6" ``` And the following imports: @@ -195,7 +195,7 @@ with [mock-server](https://www.mock-server.com/) Add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-sttp-mock-server" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-sttp-mock-server" % "1.0.6" ``` Imports: @@ -266,7 +266,7 @@ result == out To use, add the following dependency: ```scala -"com.softwaremill.sttp.tapir" %% "tapir-testing" % "1.0.5" +"com.softwaremill.sttp.tapir" %% "tapir-testing" % "1.0.6" ``` ### Shadowed endpoints