Skip to content

Commit 6cfd002

Browse files
committed
Merge remote-tracking branch 'tapir/master' into http4s-migrate-to-ember
2 parents 47a84b7 + 07a4ac5 commit 6cfd002

190 files changed

Lines changed: 1686 additions & 645 deletions

File tree

Some content is hidden

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

.github/labeler.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ labels:
66
- "build.sbt"
77
- "project/Versions.scala"
88
- "project/plugins.sbt"
9-
- "examples\\/src\\/main\\/scala\\/.*"
9+
- "examples/src/main/scala/.*"
1010
- label: "dependency"
1111
authors: ["softwaremill-ci"]
1212
files:
1313
- "build.sbt"
1414
- "project/Versions.scala"
1515
- "project/plugins.sbt"
16-
- "examples\\/src\\/main\\/scala\\/.*"
16+
- "examples/src/main/scala/.*"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ template.yaml
2222
aws-lambda-cats-effect-template.yaml
2323
aws-lambda-zio-template.yaml
2424
.scala-build
25+
.cursor
2526

2627
.bsp
2728
.idea*

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]]]] =
139139
Add the following dependency:
140140

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

145145
Then, import:

build.sbt

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ val scala2Versions = List(scala2_12, scala2_13)
2222
val scala2And3Versions = scala2Versions ++ List(scala3)
2323
val scala2_13And3Versions = List(scala2_13, scala3)
2424
val codegenScalaVersions = List(scala2_12)
25-
val ironScalaVersion = "3.6.4"
2625

2726
val examplesScalaVersion = scala3
2827
val documentationScalaVersion = scala3
@@ -177,7 +176,6 @@ lazy val rawAllAggregates = core.projectRefs ++
177176
enumeratum.projectRefs ++
178177
refined.projectRefs ++
179178
iron.projectRefs ++
180-
ironExamples.projectRefs ++
181179
zio.projectRefs ++
182180
newtype.projectRefs ++
183181
monixNewtype.projectRefs ++
@@ -454,7 +452,7 @@ lazy val core: ProjectMatrix = (projectMatrix in file("core"))
454452
scalaVersions = scala2And3Versions,
455453
settings = commonJsSettings ++ Seq(
456454
libraryDependencies ++= Seq(
457-
"org.scala-js" %%% "scalajs-dom" % "2.8.0",
455+
"org.scala-js" %%% "scalajs-dom" % "2.8.1",
458456
"io.github.cquiroz" %%% "scala-java-time" % Versions.jsScalaJavaTime % Test,
459457
"io.github.cquiroz" %%% "scala-java-time-tzdb" % Versions.jsScalaJavaTime % Test
460458
)
@@ -535,10 +533,10 @@ lazy val perfTests: ProjectMatrix = (projectMatrix in file("perf-tests"))
535533
"jackson-databind"
536534
),
537535
"io.gatling" % "gatling-test-framework" % "3.11.5" % "test" exclude ("com.fasterxml.jackson.core", "jackson-databind"),
538-
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.19.0",
536+
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.19.2",
539537
"nl.grons" %% "metrics4-scala" % Versions.metrics4Scala % Test,
540538
"com.lihaoyi" %% "scalatags" % Versions.scalaTags % Test,
541-
"io.github.classgraph" % "classgraph" % "4.8.179",
539+
"io.github.classgraph" % "classgraph" % "4.8.180",
542540
"org.http4s" %% "http4s-core" % Versions.http4s,
543541
"org.http4s" %% "http4s-dsl" % Versions.http4s,
544542
"org.http4s" %% "http4s-ember-server" % Versions.http4s,
@@ -678,8 +676,7 @@ lazy val iron: ProjectMatrix = (projectMatrix in file("integrations/iron"))
678676
libraryDependencies ++= Seq(
679677
"io.github.iltotore" %%% "iron" % Versions.iron,
680678
scalaTest.value % Test
681-
),
682-
scalaVersion := ironScalaVersion
679+
)
683680
)
684681
.jvmPlatform(scalaVersions = List(scala3), settings = commonJvmSettings)
685682
.jsPlatform(scalaVersions = List(scala3), settings = commonJsSettings)
@@ -1007,7 +1004,7 @@ lazy val pekkoGrpcExamples: ProjectMatrix = (projectMatrix in file("grpc/pekko-e
10071004
.settings(
10081005
name := "tapir-pekko-grpc-examples",
10091006
libraryDependencies ++= Seq(
1010-
"org.apache.pekko" %% "pekko-discovery" % "1.1.3",
1007+
"org.apache.pekko" %% "pekko-discovery" % "1.1.5",
10111008
slf4j
10121009
),
10131010
fork := true
@@ -1027,8 +1024,8 @@ lazy val prometheusMetrics: ProjectMatrix = (projectMatrix in file("metrics/prom
10271024
.settings(
10281025
name := "tapir-prometheus-metrics",
10291026
libraryDependencies ++= Seq(
1030-
"io.prometheus" % "prometheus-metrics-core" % "1.3.8",
1031-
"io.prometheus" % "prometheus-metrics-exposition-formats" % "1.3.8",
1027+
"io.prometheus" % "prometheus-metrics-core" % "1.3.10",
1028+
"io.prometheus" % "prometheus-metrics-exposition-formats" % "1.3.10",
10321029
scalaTest.value % Test
10331030
)
10341031
)
@@ -1402,6 +1399,7 @@ lazy val sttpStub4Server: ProjectMatrix = (projectMatrix in file("server/sttp-st
14021399
name := "tapir-sttp-stub4-server"
14031400
)
14041401
.jvmPlatform(scalaVersions = scala2And3Versions, settings = commonJvmSettings)
1402+
.jsPlatform(scalaVersions = scala2And3Versions, settings = commonJsSettings)
14051403
.dependsOn(serverCore, sttpClient4, tests % Test)
14061404

14071405
lazy val sttpMockServer: ProjectMatrix = (projectMatrix in file("server/sttp-mock-server"))
@@ -2108,10 +2106,10 @@ lazy val openapiCodegenCore: ProjectMatrix = (projectMatrix in file("openapi-cod
21082106
"com.47deg" %% "scalacheck-toolbox-datetime" % "0.7.0" % Test,
21092107
scalaOrganization.value % "scala-reflect" % scalaVersion.value,
21102108
scalaOrganization.value % "scala-compiler" % scalaVersion.value % Test,
2111-
"com.beachape" %% "enumeratum" % "1.7.6" % Test,
2112-
"com.beachape" %% "enumeratum-circe" % "1.7.5" % Test,
2113-
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.36.0" % Test,
2114-
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.36.0" % Provided
2109+
"com.beachape" %% "enumeratum" % "1.9.0" % Test,
2110+
"com.beachape" %% "enumeratum-circe" % "1.9.0" % Test,
2111+
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.37.0" % Test,
2112+
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.37.0" % Provided
21152113
)
21162114
)
21172115
.dependsOn(core % Test, circeJson % Test, jsoniterScala % Test, zioJson % Test)
@@ -2154,19 +2152,6 @@ lazy val openapiCodegenCli: ProjectMatrix = (projectMatrix in file("openapi-code
21542152
)
21552153
.dependsOn(openapiCodegenCore, core % Test, circeJson % Test, zioJson % Test)
21562154

2157-
// TODO: fold back to examples when new Scala 3 LTS is available
2158-
lazy val ironExamples = (projectMatrix in file("integrations/iron/examples"))
2159-
.settings(
2160-
name := "iron-examples",
2161-
publishArtifact := false,
2162-
Compile / run / fork := true,
2163-
commonSettings,
2164-
verifyExamplesCompileUsingScalaCli := VerifyExamplesCompileUsingScalaCli(sLog.value, sourceDirectory.value),
2165-
scalaVersion := ironScalaVersion
2166-
)
2167-
.jvmPlatform(scalaVersions = List(scala3), settings = commonJvmSettings)
2168-
.dependsOn(iron, nettyServerCats, circeJson, sttpClient4)
2169-
21702155
lazy val examples: ProjectMatrix = (projectMatrix in file("examples"))
21712156
.settings(commonSettings)
21722157
.settings(
@@ -2206,6 +2191,7 @@ lazy val examples: ProjectMatrix = (projectMatrix in file("examples"))
22062191
http4sClient,
22072192
http4sServer,
22082193
http4sServerZio,
2194+
iron,
22092195
jdkhttpServer,
22102196
jsoniterScala,
22112197
nettyServer,

context7.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://context7.com/schema/context7.json",
3+
"projectTitle": "Tapir",
4+
"description": "Rapid development of self-documenting APIs",
5+
"folders": [
6+
"generated-doc"
7+
],
8+
"rules": [
9+
"When defining Tapir endpoints, always start with the base `endpoint` value and chain methods to build input/output specifications.",
10+
"Import `sttp.tapir.*` to bring all necessary Tapir functionality into scope for endpoint definitions.",
11+
"Use `PublicEndpoint[I, E, O, R]` type alias for endpoints without security inputs instead of the full `Endpoint[Unit, I, E, O, R]` type.",
12+
"Always provide both success and error outputs for endpoints, with error outputs defined using `.errorOut()` methods.",
13+
"For JSON endpoints, add the appropriate JSON library dependency (circe, play-json, etc.) and import the corresponding package like `sttp.tapir.json.circe.*`.",
14+
"Use `jsonBody[T]` for JSON request/response bodies, ensuring both a JSON codec (Encoder/Decoder) and Schema[T] are in scope.",
15+
"Server logic functions should return `F[Either[E, O]]` where F is the effect type, E is the error type, and O is the success type.",
16+
"When using direct-style, server logic functions should return `Either[E, O]`, and the logic should be provided using .handle methods.",
17+
"When using `.serverLogicRecoverErrors()`, the error type E must extend Throwable to automatically recover from failed effects.",
18+
"Status codes default to 200 for success and 400 for errors, but can be customized using status code outputs like `.out(statusCode(StatusCode.Created))`.",
19+
"Use `.serverSecurityLogic()` followed by `.serverLogic()` for endpoints with authentication, where security logic returns Either[E, User] and main logic uses the User type.",
20+
"Tapir mappings are always bidirectional, so use `.mapTo[CaseClass]` to automatically map tuples to case classes for both input and output.",
21+
"Import `sttp.tapir.generic.auto.*` to enable automatic schema derivation for case classes used in endpoint definitions.",
22+
"Use `infallibleEndpoint` instead of `endpoint` when you want to indicate that no errors can occur in the endpoint.",
23+
"For file uploads and multipart forms, use specific inputs like `multipartBody` and ensure proper codecs are defined.",
24+
"When generating OpenAPI documentation, use `SwaggerInterpreter()` or `OpenAPIDocsInterpreter()` to create documentation from endpoint definitions.",
25+
"Use validation methods like `.validate()` on inputs to add custom validation logic that will be reflected in generated documentation."
26+
]
27+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import scala.reflect.ClassTag
3232
* regular inputs. This allows short-circuiting further processing in case security checks fail. Server logic can be provided using
3333
* [[EndpointServerLogicOps.serverSecurityLogic]] variants for secure endpoints, and [[EndpointServerLogicOps.serverLogic]] variants for
3434
* public endpoints; when using a synchronous server, you can also use the more concise [[EndpointServerLogicOps.handle]] methods, which
35-
* work the save as above, but have the "effect" type fixed to [[Identity]].
35+
* work the same as above, but have the "effect" type fixed to [[Identity]].
3636
*
3737
* A concise description of an endpoint can be generated using the [[EndpointMetaOps.show]] method.
3838
*

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
extensions = ['myst_parser', 'sphinx_rtd_theme']
4545

4646
myst_enable_extensions = ['attrs_block']
47+
myst_heading_anchors = 3
4748

4849
# Add any paths that contain templates here, relative to this directory.
4950
templates_path = ['_templates']

doc/docs/asyncapi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ val docs: AsyncAPI = AsyncAPIInterpreter().toAsyncAPI(echoWS, "Echo web socket",
3232
Such a model can then be refined, by adding details which are not auto-generated. Working with a deeply nested case
3333
class structure such as the `AsyncAPI` one can be made easier by using a lens library, e.g. [Quicklens](https://github.com/adamw/quicklens).
3434

35-
The documentation is generated in a large part basing on [schemas](../endpoint/codecs.html#schemas). Schemas can be
35+
The documentation is generated in a large part basing on [schemas](../endpoint/codecs.md#schemas). Schemas can be
3636
[automatically derived and customised](../endpoint/schemas.md).
3737

3838
Quite often, you'll need to define the servers, through which the API can be reached. Any servers provided to the

doc/endpoint/oneof.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ There are two kind of one-of inputs/outputs:
77

88
```{note}
99
`oneOf` and `oneOfBody` outputs are not related to `oneOf:` schemas when
10-
[generating](https://tapir.softwaremill.com/en/latest/docs/openapi.html) OpenAPI documentation.
10+
[generating](../docs/openapi.md) OpenAPI documentation.
1111
1212
Such schemas are generated for coproducts - e.g. `sealed trait` families - given an appropriate codec. See the
13-
documentation on [coproducts](https://tapir.softwaremill.com/en/latest/endpoint/schemas.html#sealed-traits-coproducts)
14-
for details.
13+
documentation on [coproducts](schemas.md#sealed-traits--coproducts) for details.
1514
```
1615

1716
## `oneOf` outputs

doc/endpoint/pickler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pEntity.toCodec.encode(Person("Jessica", "West"))
147147

148148
## Customising derived schemas
149149

150-
Schemas generated by picklers can be customized using annotations, just like with traditional schema derivation (see [here](schemas.html#using-annotations)). Some annotations automatically affect JSON codes:
150+
Schemas generated by picklers can be customized using annotations, just like with traditional schema derivation (see [here](schemas.md#using-annotations)). Some annotations automatically affect JSON codes:
151151

152152
* `@encodedName` determines JSON field name
153153
* `@default` sets default value if the field is missing in JSON

0 commit comments

Comments
 (0)