Highlights
Endpoint API
Codec Changes
Header and Query codecs are now Schema
based. We added methods on QueryParams
and Headers
that set and get values based on Schema
. This also enables to use case classes to get/set header/query values that are simple wrappers or have multiple primitive/collection fields. Docs have been added for more details.
case class Foo(a: Int, b: SimpleWrapper, c: NonEmptyChunk[String], chunk: Chunk[String])
val headersFoo = Headers("a" -> "1", "b" -> "foo", "c" -> "2", "chunk" -> "foo", "chunk" -> "bar")
val foo = headersFoo.header[Foo]
Scala 3 Union Type support
Here an example
val unionWithErrorEndpoint
: Endpoint[Unit, Unit, NotFound[EntityId] | String, UUID | Unit, AuthType.None] =
Endpoint(Method.GET / "api" / "union-with-error")
.out[UUID]
.orOut[Unit](Status.NoContent)
.outError[NotFound[EntityId]](Status.NotFound)
.orOutError[String](Status.BadRequest)
For more details, please check the added documentation.
Performance improvements
We merged multiple PRs for improving routes look up time.
Also zio-schema
and zio-json
get huge performance boosts in recent versions, thanks to @plokhotnyuk and the versions have been updated in zio-http
Here is some before after comparison
One Scope
per request handling
Before you could require a scope in a request handler and bubble this up to the apps default Scope. Since after an HTTP request its resources should be cleaned and not at the end of the Server app, this was a possible source for bugs.
Now, if a handler/route/routes needs a scope, you have to provide one. Adding a route to the server that requires a scope will lead to a compile error.
You can either use Handler.scoped
or ZIO.scoped
to provide a scope where needed.
Changes
- Update parsers to 4.13.3 @zio-scala-steward[bot] (#3390)
- Update sbt-github-actions to 0.25.0 @zio-scala-steward[bot] (#3388)
- Update scalafmt-core, scalafmt-dynamic to 3.9.3 @zio-scala-steward[bot] (#3391)
- Fix incorrect generation of URLs in HttpCliApp.fromEndpoints @franbh (#3386)
- Update protobuf-java to 4.30.0 @zio-scala-steward[bot] (#3387)
- Make newly added Routes take precedence over old ones (#3066) @987Nabil (#3337)
- Update scalafmt-core, scalafmt-dynamic to 3.9.2 @zio-scala-steward[bot] (#3370)
- Update zio-cli to 0.7.1 @zio-scala-steward[bot] (#3379)
- fix: display endpoint documentation in swagger ui @mobley-trent (#3221)
- Align Client SSE support to HTML specification @disordered (#3312)
- docs: fix broken link @igneus (#3377)
- Update zio-schema to 1.6.4 @plokhotnyuk (#3384)
- Update tapir-http4s-server, ... to 1.11.17 @zio-scala-steward[bot] (#3378)
- Update sbt, scripted-plugin to 1.10.10 @zio-scala-steward[bot] (#3382)
- Update zio-json-yaml to 0.7.38 @zio-scala-steward[bot] (#3380)
- Update zio-json-yaml to 0.7.37 @zio-scala-steward[bot] (#3375)
- Provide a
Scope
per server call (#3197) @987Nabil (#3276) - Docs: address some raw edges @igneus (#3354)
- Cookie-based Authentication Example @khajavi (#3366)
- Update tapir-http4s-server, ... to 1.11.16 @zio-scala-steward[bot] (#3368)
- Update zio-json-yaml to 0.7.36 @zio-scala-steward[bot] (#3369)
- Update netty-codec-http, ... to 4.1.119.Final @zio-scala-steward[bot] (#3364)
- Update zio-json-yaml to 0.7.35 @zio-scala-steward[bot] (#3363)
- Update zio, zio-streams, zio-test, ... to 2.1.16 @zio-scala-steward[bot] (#3362)
- Update slf4j-api, slf4j-simple to 2.0.17 @zio-scala-steward[bot] (#3360)
- Update zio-json-yaml to 0.7.33 @zio-scala-steward[bot] (#3359)
- Update zio-json-yaml to 0.7.31 @zio-scala-steward[bot] (#3358)
- Update zio-json-yaml to 0.7.30 @zio-scala-steward[bot] (#3356)
- Update scalafmt-core, scalafmt-dynamic to 3.9.1 @zio-scala-steward[bot] (#3353)
- Update zio-json-yaml to 0.7.28 @zio-scala-steward[bot] (#3355)
- Update parsers to 4.13.2 @zio-scala-steward[bot] (#3352)
- Update zio-schema to 1.6.3 @plokhotnyuk (#3351)
- Update zio-json-yaml to 0.7.26 @zio-scala-steward[bot] (#3348)
- Make EndpointExecutor work with batched clients (#3187) @987Nabil (#3313)
- Update sbt-scalafix to 0.14.2 @zio-scala-steward[bot] (#3346)
- Update zio-json-yaml to 0.7.25 @zio-scala-steward[bot] (#3344)
- Schema based
HeaderOps
(#3310) @987Nabil (#3311) - Add tapErrorZIO and tapErrorCauseZIO to Route and Routes @tjarvstrand (#2755)
- Update client3:core to 3.10.3 @zio-scala-steward[bot] (#3338)
- Add Object Mapper Example @khajavi (#3293)
- Update scala3-compiler, scala3-library, ... to 3.3.5 @zio-scala-steward[bot] (#3329)
- Update protobuf-java to 4.29.3 @zio-scala-steward[bot] (#3318)
- Update tapir-http4s-server, ... to 1.11.15 @zio-scala-steward[bot] (#3339)
- Update zio-cli to 0.7.0 @zio-scala-steward[bot] (#3323)
- Update zio-json-yaml to 0.7.23 @zio-scala-steward[bot] (#3340)
- Update parsers to 4.13.1.1 @zio-scala-steward[bot] (#3333)
- Update scala-collection-compat to 2.13.0 @zio-scala-steward[bot] (#3330)
- Update scala-java-time, ... to 2.6.0 @zio-scala-steward[bot] (#3328)
- Update tapir-http4s-server, ... to 1.5.5 @zio-scala-steward[bot] (#3320)
- Add test to ensure, that nested routes are only available nested (#3243) @987Nabil (#3304)
- Update zio-sbt-website to 0.4.0-alpha.31 @zio-scala-steward[bot] (#3326)
- Update zio-config, zio-config-magnolia, ... to 4.0.3 @zio-scala-steward[bot] (#3324)
- Update sbt, scripted-plugin to 1.10.7 @zio-scala-steward[bot] (#3331)
- Update mdoc, sbt-scalafmt to 2.5.4 @zio-scala-steward[bot] (#3332)
- Update scalafmt-core, scalafmt-dynamic to 3.9.0 @zio-scala-steward[bot] (#3334)
- Update slf4j-api, slf4j-simple to 2.0.16 @zio-scala-steward[bot] (#3335)
- Update sbt-github-actions to 0.24.0 @zio-scala-steward[bot] (#3317)
- More efficient root path look up (#3302) @987Nabil (#3303)
- Update sbt-shading to 2.1.5 @zio-scala-steward[bot] (#3327)
- Update zio-json-yaml to 0.7.21 @zio-scala-steward[bot] (#3325)
- Update zio, zio-streams, zio-test, ... to 2.1.15 @zio-scala-steward[bot] (#3322)
- Update compilerplugin, scalapb-runtime to 0.11.17 @zio-scala-steward[bot] (#3321)
- Update client3:core to 3.9.8 @zio-scala-steward[bot] (#3319)
- Update sbt-ci-release to 1.9.2 @zio-scala-steward[bot] (#3316)
- Update jwt-core to 10.0.4 @zio-scala-steward[bot] (#3315)
- Update brotli4j to 1.18.0 @zio-scala-steward[bot] (#3314)
- Update Netty @guizmaii (#3297)
- CI: Fix release-drafter @guizmaii (#3299)
- Schema based query ops (#3176) @987Nabil (#3295)
- Add RoundtripBenchmark (#3291) @987Nabil (#3292)
- Schema based header codecs, unified with query codecs (#3232) @987Nabil (#3270)
- Fix decoding of
JsonSchema
properties from JSON @plokhotnyuk (#3287) - Update Netty to latest version,
4.1.117.Final
@guizmaii (#3279) - Use HashMap for literals look up (#2960) @987Nabil (#3277)
- Revert "[sbt-gen] sbt plugin for openapi to endpoints codegen" @hochgi (#3278)
- Option to generate examples for OpenAPI (#3196) @987Nabil (#3273)
- Fix publish CI @987Nabil (#3275)
- Use empty body for
Unit
payload in Endpoint (#3258) @987Nabil (#3271) - Fix Issues with Line Numbering in Documentation Examples @khajavi (#3265)
- added basic documentation for the openapi codegen sbt plugin @hochgi (#3262)
- [gen] adding support for "Any" and "AnyObject" as json in codegen @hochgi (#3205)
- fix: Parse passwords with arbitrary colons @mobley-trent (#3201)
- [sbt-gen] sbt plugin for openapi to endpoints codegen @hochgi (#3225)
- Optimize some
zio.http.endpoint.Endpoint
code @guizmaii (#3213) - Optimise
zio.http.Response.fromServerSentEvents
@guizmaii (#3238) - Optimise
optBinaryCodec#streamDecoder
@guizmaii (#3237) - Bump netty for CVE-2024-47535 @russwyte (#3241)
- Exclude
sourcecode
from scalameta parsers @nafg (#3195) - Fix & typo @gkfabs (#3189)
- Endpoint Scala 3 API for union types output (#3125) @987Nabil (#3156)
- Endpoint gen additional types @gregor-rayman (#3249)
- Clean
zio.http.codec.internal.AtomizedCodecs
code @guizmaii (#3212) - Fix: Mimetype application/x-zip-compressed interpreted as a text field @varshith257 (#3203)
- Optimise
zio.http.endpoint.Endpoint.implementHandler
@guizmaii (#3236) - Handler factory method for functions returning Either @jczuchnowski (#3230)
- Further optimise
zio.http.Body.FileBody.asStream
code @guizmaii (#3234) - Optimise
zio.http.endpoint.openapi.JsonSchema.fromZSchemaMulti
@guizmaii (#3239) - Fix build pipeline @987Nabil (#3253)
- ZClient enhancements for URL and path @otobrglez (#3227)
- Optimize
zio.http.codec.internal.EncoderDecoder.Single.decodeBody
code @guizmaii (#3211) - Optimise
zio.http.Body.FileBody.asStream
code @guizmaii (#3215) - Fix "ZIO.fail(throw" @andrzejressel (#3220)
- Update ZIO to 2.1.11 @kyri-petrou (#3190)
- Install sbt in workflows @987Nabil (#3192)
- Simple default layer for test server (#3094) @987Nabil (#3161)
- Fix
Scope
usage inServerSentEventEndpointSpec
@kyri-petrou (#3182) - Fix multiple issues with docs in generating OpenAPI (#3132) @987Nabil (#3147)
- Allow up to 22 error for
Endpoint#outErrors
(#3130) @987Nabil (#3148) - Fix OpenAPIGen for opt payloads @987Nabil (#3181)
- Sandbox routes later & don't pass handled responses into error handlers @mschuwalow (#3146)
- Encode opt query params correctly in open api (#3127) @987Nabil (#3152)
- Add more options to the SSL configuration @varshith257 (#3139)
- Special case encode optional for HttpCodec.Content (#3144) @987Nabil (#3167)
- Ignore empty appending to RoutePattern and render empty as slash (#3110) @987Nabil (#3121)
- [gen] verify issue #3077 is fixed @hochgi (#3178)
- Issue 3165: Additional PR tasks @scottweaver (#3179)
- Issue 3165: Fix Forwarded Header rendering @scottweaver (#3166)
- Add docs for ErrorResponseConfig (#2198) @987Nabil (#3175)
- Make
JsonSchema.fromSerializableSchema
package private @guersam (#3170) - Changes the default Endpoint.outStream[X] encoding to produce a JSON array @gregor-rayman (#3122)
- Fix ScalaJS Compilation by Removing JVM-specific java.util.Objects References in PathCodecPlatformSpecific @asr2003 (#3155)
- Fix #3101 Code gen schema import missing @nafg (#3153)
- Fix #3103 Only last response is generated into Endpoint code @nafg (#3151)
- Optimizations for request execution happy path @kyri-petrou (#3143)
- fix OpenAPI code gen not quoting arbitrary header names @geeeezmo (#3136)