From 150d73d020779a01506df30c1b8c7f5fbf597113 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Thomasset Date: Thu, 30 Jul 2026 10:45:37 +0200 Subject: [PATCH] Update Scala3 recursive type schema definition As `implicit` defs are no longer supported in scala 3, this commit update the documentation for describing how to derive the Schema for a recursive type in Scala 3 using the by-name given syntax instead of an `implicit def` --- doc/endpoint/schemas.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/endpoint/schemas.md b/doc/endpoint/schemas.md index 9971ab0271..2d86820dac 100644 --- a/doc/endpoint/schemas.md +++ b/doc/endpoint/schemas.md @@ -85,16 +85,16 @@ This method may be used both with automatic and semi-automatic derivation. ### Derivation for recursive types -In Scala3, any schemas for recursive types need to be provided as typed `implicit def` (not a `given`)! +In Scala3, any schemas for recursive types need to be provided using by-name givens (not a direct `given`)! For example: ```scala mdoc:silent case class RecursiveTest(data: List[RecursiveTest]) object RecursiveTest: - implicit def f1Schema: Schema[RecursiveTest] = Schema.derived[RecursiveTest] + given f1Schema: () => Schema[RecursiveTest] = Schema.derived[RecursiveTest] ``` -The implicit doesn't have to be defined in the companion object, just anywhere in scope. This applies to cases where +The `given` doesn't have to be defined in the companion object, just anywhere in scope. This applies to cases where the schema is looked up implicitly, e.g. for `jsonBody`. ### Derivation for union types