Skip to content

Commit 2c58501

Browse files
committed
Merge remote-tracking branch 'tapir/master' into http4s-migrate-to-ember
2 parents cfb0224 + bb3a46f commit 2c58501

File tree

146 files changed

+766
-554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+766
-554
lines changed

.git-blame-ignore-revs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ e003ec3b61e3bd582ae6a5200177fa6433099c09
5151

5252
# Scala Steward: Reformat with scalafmt 3.8.3
5353
d743a8c6f793a5b30c8f14cfd57a367a4ffee4cd
54+
55+
# Scala Steward: Reformat with scalafmt 3.8.4
56+
ee33c92f9d42ab5eda8377d409ea32e461dc169d
57+
58+
# Scala Steward: Reformat with scalafmt 3.8.5
59+
4f7c0592e6d487bce3fa60ffabe366517667912c

.github/workflows/ci.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112
name: 'tests-results-${{ matrix.scala-version }}-${{ matrix.target-platform }}-${{ matrix.java }}'
113113
path: '**/test-reports/TEST*.xml'
114114
- name: Prepare release notes
115-
uses: release-drafter/release-drafter@v5
115+
uses: release-drafter/release-drafter@v6
116116
with:
117117
config-name: release-drafter.yml
118118
env:
@@ -189,7 +189,7 @@ jobs:
189189
COMMIT_MSG: ${{ github.event.head_commit.message }}
190190
- name: Publish release notes
191191
if: matrix.java == '11'
192-
uses: release-drafter/release-drafter@v5
192+
uses: release-drafter/release-drafter@v6
193193
with:
194194
config-name: release-drafter.yml
195195
publish: true
@@ -200,7 +200,7 @@ jobs:
200200
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
201201

202202

203-
# `automerge` label is attached iff there is exactly one file changed by steward and this file belongs to a
203+
# `automerge` label is attached if there is exactly one file changed by steward and this file belongs to a
204204
# whitelist specified by `labeler.yml`
205205
label:
206206
name: Attach automerge label
@@ -216,16 +216,31 @@ jobs:
216216
env:
217217
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
218218

219-
auto-merge:
220-
name: Auto merge
221-
# only for PRs by softwaremill-ci and dependabot
222-
if: github.event.pull_request.user.login == 'softwaremill-ci' ||
223-
github.event.pull_request.user.login == 'dependabot[bot]'
219+
auto-merge-softwaremill-ci:
220+
name: Auto merge softwaremill-ci
221+
# only for PRs by softwaremill-ci
222+
if: github.event.pull_request.user.login == 'softwaremill-ci'
224223
needs: [ ci, mima, label ]
225224
runs-on: ubuntu-24.04
226225
steps:
227-
- id: automerge
228-
name: automerge
226+
- id: automerge-softwaremill-ci
227+
name: automerge-softwaremill-ci
228+
uses: "pascalgn/[email protected]"
229+
env:
230+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
231+
MERGE_METHOD: "squash"
232+
233+
# separate `automerge` job for dependabot as it doesn't need label job
234+
# labeling is done by dependabot itself
235+
auto-merge-dependabot:
236+
name: Auto merge dependabot
237+
# only for PRs by dependabot
238+
if: github.event.pull_request.user.login == 'dependabot[bot]'
239+
needs: [ ci, mima ]
240+
runs-on: ubuntu-24.04
241+
steps:
242+
- id: automerge-dependabot
243+
name: automerge-dependabot
229244
uses: "pascalgn/[email protected]"
230245
env:
231246
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.scalafmt.conf

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
version = 3.8.3
1+
version = 3.8.5
22
maxColumn = 140
3-
runner.dialect = scala3
3+
runner.dialect = scala213
44
fileOverride {
5-
"glob:**/scala-2/**" {
6-
runner.dialect = scala213
5+
"glob:**/scala-3/**" {
6+
runner.dialect = scala3
77
}
8-
"glob:**/enumeratum/**" {
9-
runner.dialect = scala213
10-
}
8+
"glob:**/examples/**" {
9+
runner.dialect = scala3
10+
}
11+
"glob:**/integrations/iron/**" {
12+
runner.dialect = scala3
13+
}
14+
"glob:**/json/pickler/**" {
15+
runner.dialect = scala3
16+
}
17+
"glob:**/server/netty-server/sync/**" {
18+
runner.dialect = scala3
19+
}
1120
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ val booksListingRequest: Request[DecodeResult[Either[String, List[Book]]], Any]
139139
Add the following dependency:
140140

141141
```sbt
142-
"com.softwaremill.sttp.tapir" %% "tapir-core" % "1.11.12"
142+
"com.softwaremill.sttp.tapir" %% "tapir-core" % "1.11.13"
143143
```
144144

145145
Then, import:

build.sbt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import scala.concurrent.duration.DurationInt
1515
import scala.sys.process.Process
1616

1717
val scala2_12 = "2.12.20"
18-
val scala2_13 = "2.13.15"
18+
val scala2_13 = "2.13.16"
1919
val scala3 = "3.3.4"
2020

2121
val scala2Versions = List(scala2_12, scala2_13)
@@ -425,7 +425,7 @@ lazy val core: ProjectMatrix = (projectMatrix in file("core"))
425425
libraryDependencies ++= {
426426
CrossVersion.partialVersion(scalaVersion.value) match {
427427
case Some((3, _)) =>
428-
Seq("com.softwaremill.magnolia1_3" %%% "magnolia" % "1.3.8")
428+
Seq("com.softwaremill.magnolia1_3" %%% "magnolia" % "1.3.9")
429429
case _ =>
430430
Seq(
431431
"com.softwaremill.magnolia1_2" %%% "magnolia" % "1.1.10",
@@ -2065,6 +2065,7 @@ lazy val examples: ProjectMatrix = (projectMatrix in file("examples"))
20652065
libraryDependencies ++= Seq(
20662066
"com.softwaremill.sttp.apispec" %% "asyncapi-circe-yaml" % Versions.sttpApispec,
20672067
"com.softwaremill.sttp.client3" %% "core" % Versions.sttp,
2068+
"com.softwaremill.sttp.client3" %% "circe" % Versions.sttp,
20682069
"com.softwaremill.sttp.client3" %% "pekko-http-backend" % Versions.sttp,
20692070
"com.softwaremill.sttp.client3" %% "async-http-client-backend-fs2" % Versions.sttp,
20702071
"com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % Versions.sttp,

core/src/main/scala-2/sttp/tapir/macros/CodecMacros.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import sttp.tapir.Codec
77
trait CodecMacros {
88

99
/** Creates a codec for an enumeration, where the validator is derived using [[sttp.tapir.Validator.derivedEnumeration]]. This requires
10-
* that all subtypes of the sealed hierarchy `T` must be `object`s.
10+
* that all subtypes of the sealed hierarchy `T` must be `object` s.
1111
*
1212
* This method cannot be implicit, as there's no way to constraint the type `T` to be a sealed trait / class enumeration, so that this
1313
* would be invoked only when necessary.

core/src/main/scala-2/sttp/tapir/macros/SchemaMacros.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait SchemaMacros[T] {
1111
/** Modifies nested schemas for case classes and case class families (sealed traits / enums), accessible with `path`, using the given
1212
* `modification` function. To traverse collections, use `.each`.
1313
*
14-
* Should only be used if the schema hasn't been created by `.map`ping another one. In such a case, the shape of the schema doesn't
14+
* Should only be used if the schema hasn't been created by `.map` ping another one. In such a case, the shape of the schema doesn't
1515
* correspond to the type `T`, but to some lower-level representation of the type.
1616
*
1717
* If the shape of the schema doesn't correspond to the path, the schema remains unchanged.
@@ -60,7 +60,7 @@ trait SchemaCompanionMacros extends SchemaMagnoliaDerivation {
6060
def derived[T]: Schema[T] = macro Magnolia.gen[T]
6161

6262
/** Creates a schema for an enumeration, where the validator is derived using [[sttp.tapir.Validator.derivedEnumeration]]. This requires
63-
* that all subtypes of the sealed hierarchy `T` must be `object`s.
63+
* that all subtypes of the sealed hierarchy `T` must be `object` s.
6464
*
6565
* This method cannot be implicit, as there's no way to constraint the type `T` to be a sealed trait / class enumeration, so that this
6666
* would be invoked only when necessary.

core/src/main/scala-2/sttp/tapir/macros/ValidatorMacros.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import sttp.tapir.internal.ValidatorEnumerationMacro
55

66
trait ValidatorMacros {
77

8-
/** Creates an enum validator where all subtypes of the sealed hierarchy `T` are `object`s. This enumeration will only be used for
8+
/** Creates an enum validator where all subtypes of the sealed hierarchy `T` are `object` s. This enumeration will only be used for
99
* documentation, as a value outside of the allowed values will not be decoded in the first place (the decoder has no other option than
1010
* to fail).
1111
*/

core/src/main/scala-3-2.13+/sttp/tapir/CodecExtensions2.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import sttp.tapir.model.Delimited
44

55
trait CodecExtensions2 {
66

7-
/** Creates a codec which handles values delimited using `D`. The implicit `T`-codec is used for handling each individual value.
7+
/** Creates a codec which handles values delimited using `D`. The implicit `T` -codec is used for handling each individual value.
88
*
9-
* Upon decoding, the string is split using the delimiter, and then decoded using the `T`-codec. Upon encoding, the values are first
10-
* encoded using the `T`-codec, and then combined using the delimiter.
9+
* Upon decoding, the string is split using the delimiter, and then decoded using the `T` -codec. Upon encoding, the values are first
10+
* encoded using the `T` -codec, and then combined using the delimiter.
1111
*
1212
* The codec's schema has the `explode` attribute set to `false`.
1313
*/

core/src/main/scala-3/sttp/tapir/macros/CodecMacros.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import sttp.tapir.internal.CodecValueClassMacro
77
trait CodecMacros:
88

99
/** Creates a codec for an enumeration, where the validator is derived using [[sttp.tapir.Validator.derivedEnumeration]]. This requires
10-
* that all subtypes of the sealed hierarchy `T` must be `object`s.
10+
* that all subtypes of the sealed hierarchy `T` must be `object` s.
1111
*
1212
* This method cannot be implicit, as there's no way to constraint the type `T` to be a sealed trait / class enumeration, so that this
1313
* would be invoked only when necessary.

core/src/main/scala-3/sttp/tapir/macros/SchemaMacros.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trait SchemaMacros[T] { this: Schema[T] =>
1212
/** Modifies nested schemas for case classes and case class families (sealed traits / enums), accessible with `path`, using the given
1313
* `modification` function. To traverse collections, use `.each`.
1414
*
15-
* Should only be used if the schema hasn't been created by `.map`ping another one. In such a case, the shape of the schema doesn't
15+
* Should only be used if the schema hasn't been created by `.map` ping another one. In such a case, the shape of the schema doesn't
1616
* correspond to the type `T`, but to some lower-level representation of the type.
1717
*
1818
* If the shape of the schema doesn't correspond to the path, the schema remains unchanged.
@@ -41,12 +41,15 @@ private[tapir] object SchemaMacros {
4141
.exists(modifyType.endsWith)
4242

4343
tree match {
44+
4445
/** Field access */
4546
case Select(deep, ident) =>
4647
toPath(deep, PathElement.TermPathElement(ident) :: acc)
48+
4749
/** Method call with no arguments and using clause */
4850
case Apply(Apply(TypeApply(Ident(f), _), idents), _) if typeSupported(f) => {
4951
val newAcc = acc match {
52+
5053
/** replace the term controlled by quicklens */
5154
case PathElement.TermPathElement(term, xargs @ _*) :: rest => PathElement.FunctorPathElement(f, term, xargs: _*) :: rest
5255
case elements => report.errorAndAbort(s"Invalid use of path elements [${elements.mkString(", ")}]. $ShapeInfo, got: ${tree}")
@@ -64,6 +67,7 @@ private[tapir] object SchemaMacros {
6467
}
6568

6669
val pathElements = path.asTerm match {
70+
6771
/** Single inlined path */
6872
case Inlined(_, _, Block(List(DefDef(_, _, _, Some(p))), _)) =>
6973
toPath(p, List.empty)
@@ -157,7 +161,7 @@ trait SchemaCompanionMacros extends SchemaMagnoliaDerivation {
157161
}
158162

159163
/** Creates a schema for an enumeration, where the validator is derived using [[sttp.tapir.Validator.derivedEnumeration]]. This requires
160-
* that this is an `enum`, where all cases are parameterless, or that all subtypes of the sealed hierarchy `T` are `object`s.
164+
* that this is an `enum`, where all cases are parameterless, or that all subtypes of the sealed hierarchy `T` are `object` s.
161165
*
162166
* This method cannot be implicit, as there's no way to constraint the type `T` to be an enum / sealed trait or class enumeration, so
163167
* that this would be invoked only when necessary.

core/src/main/scala-3/sttp/tapir/macros/ValidatorMacros.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import scala.quoted.*
99
trait ValidatorMacros {
1010

1111
/** Creates an enum validator for an `enum` where all cases are parameterless, or where all subtypes of the sealed hierarchy `T` are
12-
* `object`s. This enumeration will only be used for documentation, as a value outside of the allowed values will not be decoded in the
12+
* `object` s. This enumeration will only be used for documentation, as a value outside of the allowed values will not be decoded in the
1313
* first place (the decoder has no other option than to fail).
1414
*/
1515
inline def derivedEnumeration[T]: Validator.Enumeration[T] = ${ ValidatorMacros.derivedEnumerationImpl[T] }

core/src/main/scala-3/sttp/tapir/macros/union_derivation.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,4 @@ private[tapir] object UnionDerivation:
5656
report.errorAndAbort(s"${o.show} is not a subtype of ${bound.show}")
5757

5858
transformTypes(tpe).distinct.map(_.asType match
59-
case '[t] => '{ constValue[t] }
60-
)
59+
case '[t] => '{ constValue[t] })

core/src/main/scala/sttp/tapir/Codec.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ trait Codec[L, H, +CF <: CodecFormat] { outer =>
145145
/** Adds a validator to the codec's schema.
146146
*
147147
* Note that validation is run on a fully decoded value. That is, during decoding, first the decoding functions are run, followed by
148-
* validations. Hence any functions provided in subsequent `.map`s or `.mapDecode`s will be invoked before validation.
148+
* validations. Hence any functions provided in subsequent `.map` s or `.mapDecode` s will be invoked before validation.
149149
*
150150
* @see
151151
* [[mapValidate]]
@@ -155,23 +155,23 @@ trait Codec[L, H, +CF <: CodecFormat] { outer =>
155155
/** Adds a validator which validates the option's element, if it is present.
156156
*
157157
* Note that validation is run on a fully decoded value. That is, during decoding, first the decoding functions are run, followed by
158-
* validations. Hence any functions provided in subsequent `.map`s or `.mapDecode`s will be invoked before validation.
158+
* validations. Hence any functions provided in subsequent `.map` s or `.mapDecode` s will be invoked before validation.
159159
*
160-
* Should only be used if the schema hasn't been created by `.map`ping another one, but directly from `Schema[U]`. Otherwise the shape of
161-
* the schema doesn't correspond to the type `T`, but to some lower-level representation of the type. This might cause invalid results at
162-
* run-time.
160+
* Should only be used if the schema hasn't been created by `.map` ping another one, but directly from `Schema[U]`. Otherwise the shape
161+
* of the schema doesn't correspond to the type `T`, but to some lower-level representation of the type. This might cause invalid results
162+
* at run-time.
163163
*/
164164
def validateOption[U](v: Validator[U])(implicit hIsOptionU: H =:= Option[U]): Codec[L, H, CF] =
165165
schema(_.modifyUnsafe[U](Schema.ModifyCollectionElements)(_.validate(v)))
166166

167167
/** Adds a validator which validates each element in the collection.
168168
*
169169
* Note that validation is run on a fully decoded value. That is, during decoding, first the decoding functions are run, followed by
170-
* validations. Hence any functions provided in subsequent `.map`s or `.mapDecode`s will be invoked before validation.
170+
* validations. Hence any functions provided in subsequent `.map` s or `.mapDecode` s will be invoked before validation.
171171
*
172-
* Should only be used if the schema hasn't been created by `.map`ping another one, but directly from `Schema[U]`. Otherwise the shape of
173-
* the schema doesn't correspond to the type `T`, but to some lower-level representation of the type. This might cause invalid results at
174-
* run-time.
172+
* Should only be used if the schema hasn't been created by `.map` ping another one, but directly from `Schema[U]`. Otherwise the shape
173+
* of the schema doesn't correspond to the type `T`, but to some lower-level representation of the type. This might cause invalid results
174+
* at run-time.
175175
*/
176176
def validateIterable[C[X] <: Iterable[X], U](v: Validator[U])(implicit hIsCU: H =:= C[U]): Codec[L, H, CF] =
177177
schema(_.modifyUnsafe[U](Schema.ModifyCollectionElements)(_.validate(v)))

core/src/main/scala/sttp/tapir/EndpointIO.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ sealed trait EndpointTransput[T] extends EndpointTransputMacros[T] {
7474
/** Adds a validator.
7575
*
7676
* Note that validation is run on a fully decoded value. That is, during decoding, first the decoding functions are run, followed by
77-
* validations. Hence any functions provided in subsequent `.map`s or `.mapDecode`s will be invoked before validation.
77+
* validations. Hence any functions provided in subsequent `.map` s or `.mapDecode` s will be invoked before validation.
7878
*
7979
* @see
8080
* [[mapValidate]]
@@ -103,7 +103,7 @@ object EndpointTransput {
103103

104104
/** Adds a validator which validates the option's element, if it is present.
105105
*
106-
* Should only be used if the schema hasn't been created by `.map`ping another one, but directly from `Schema[U]`. Otherwise the shape
106+
* Should only be used if the schema hasn't been created by `.map` ping another one, but directly from `Schema[U]`. Otherwise the shape
107107
* of the schema doesn't correspond to the type `T`, but to some lower-level representation of the type. This might cause invalid
108108
* results at run-time.
109109
*/
@@ -112,7 +112,7 @@ object EndpointTransput {
112112

113113
/** Adds a validator which validates each element in the collection.
114114
*
115-
* Should only be used if the schema hasn't been created by `.map`ping another one, but directly from `Schema[U]`. Otherwise the shape
115+
* Should only be used if the schema hasn't been created by `.map` ping another one, but directly from `Schema[U]`. Otherwise the shape
116116
* of the schema doesn't correspond to the type `T`, but to some lower-level representation of the type. This might cause invalid
117117
* results at run-time.
118118
*/

core/src/main/scala/sttp/tapir/Tapir.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
363363
oneOfVariantValueMatcher(code, output)(exactMatch(rest.toSet + firstExactValue))
364364

365365
/** Create a one-of-variant which uses `output` if the provided value equals the singleton value. The `output` shouldn't map to any
366-
* values, that is, it should be `Unit`-typed. The entire variant is, on the other hand, typed with the singleton's type `T`.
366+
* values, that is, it should be `Unit` -typed. The entire variant is, on the other hand, typed with the singleton's type `T`.
367367
*
368368
* Should be used in [[oneOf]] output descriptions.
369369
*
@@ -374,7 +374,7 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
374374
oneOfVariantValueMatcher(output.and(emptyOutputAs(singletonValue)))({ case a: Any => a == singletonValue })
375375

376376
/** Create a one-of-variant which uses `output` if the provided value equals the singleton value. The `output` shouldn't map to any
377-
* values, that is, it should be `Unit`-typed. The entire variant is, on the other hand, typed with the singleton's type `T`.
377+
* values, that is, it should be `Unit` -typed. The entire variant is, on the other hand, typed with the singleton's type `T`.
378378
*
379379
* Adds a fixed status-code output with the given value.
380380
*

core/src/main/scala/sttp/tapir/typelevel/ParamConcat.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package sttp.tapir.typelevel
22

33
/** Concatenates two parameter lists into one. Each parameter list can be either a single type, or a tuple.
44
*
5-
* The arity of a type if `0` if it's `Unit`/`Nothing`, as these types act as a neutral element in the tuple-concatenation operation that
5+
* The arity of a type if `0` if it's `Unit` /`Nothing`, as these types act as a neutral element in the tuple-concatenation operation that
66
* takes place when combining inputs/outputs.
77
*
88
* The arity of a type is `1` if it's a "singular" type (as viewed at compile-time; at run-time, the value might in fact be a tuple).

docs/apispec-docs/src/main/scala/sttp/tapir/docs/apispec/schema/TSchemaToASchema.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ private[docs] class TSchemaToASchema(
112112
// The primary motivation for using schema name as fallback title is to improve Swagger UX with
113113
// `oneOf` schemas in OpenAPI 3.1. See https://github.com/softwaremill/tapir/issues/3447 for details.
114114
def fallbackTitle = tschema.name.map(fallbackSchemaTitle)
115-
115+
116116
val const = tschema.attribute(TSchema.EncodedDiscriminatorValue.Attribute).map(_.v).map(v => ExampleSingleValue(v))
117-
117+
118118
oschema
119119
.copy(title = titleFromAttr.orElse(fallbackTitle))
120120
.copy(uniqueItems = tschema.attribute(UniqueItems.Attribute).map(_.uniqueItems))

0 commit comments

Comments
 (0)