diff --git a/build.sbt b/build.sbt index cbfa875c..d1674809 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val enumeratumVersion = "1.7.5" val jacksonVersion = "2.18.2" val magnolia2Version = "0.17.0" val magnolia3Version = "1.3.8" -val munitVersion = "1.0.0" +val munitVersion = "1.1.0" val refinedVersion = "0.11.3" val scalaCollectionCompatVersion = "2.12.0" val shapeless3Version = "3.4.3" diff --git a/modules/core/src/main/scala-2.12/vulcan/internal/converters.scala b/modules/core/src/main/scala-2.12/vulcan/internal/converters.scala index ff12f928..0c80be28 100644 --- a/modules/core/src/main/scala-2.12/vulcan/internal/converters.scala +++ b/modules/core/src/main/scala-2.12/vulcan/internal/converters.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala-2.13+/vulcan/internal/converters.scala b/modules/core/src/main/scala-2.13+/vulcan/internal/converters.scala index 3e8e5163..79e4b0eb 100644 --- a/modules/core/src/main/scala-2.13+/vulcan/internal/converters.scala +++ b/modules/core/src/main/scala-2.13+/vulcan/internal/converters.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala-2/AvroDoc.scala b/modules/core/src/main/scala-2/AvroDoc.scala index ed7d394e..6015ab06 100644 --- a/modules/core/src/main/scala-2/AvroDoc.scala +++ b/modules/core/src/main/scala-2/AvroDoc.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala-2/AvroNamespace.scala b/modules/core/src/main/scala-2/AvroNamespace.scala index e0addb36..057195bb 100644 --- a/modules/core/src/main/scala-2/AvroNamespace.scala +++ b/modules/core/src/main/scala-2/AvroNamespace.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala-2/vulcan/CodecCompat.scala b/modules/core/src/main/scala-2/vulcan/CodecCompat.scala index ba1a15eb..9cf9a01b 100644 --- a/modules/core/src/main/scala-2/vulcan/CodecCompat.scala +++ b/modules/core/src/main/scala-2/vulcan/CodecCompat.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala-2/vulcan/internal/tags.scala b/modules/core/src/main/scala-2/vulcan/internal/tags.scala index 2576fb0a..9b253cd0 100644 --- a/modules/core/src/main/scala-2/vulcan/internal/tags.scala +++ b/modules/core/src/main/scala-2/vulcan/internal/tags.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,15 @@ private[vulcan] object tags { doc.substring(1, doc.length - 1) } + final def aliasFrom[A](tag: WeakTypeTag[A]): Seq[String] = + tag.tpe.typeSymbol.annotations.collectFirst { + case annotation + if annotation.tree.tpe.typeSymbol.fullName == "vulcan.AvroAlias" || + annotation.tree.tpe.typeSymbol.fullName == "vulcan.generic.AvroAlias" => + val doc = annotation.tree.children.last.toString + doc.substring(1, doc.length - 1) + }.toList + final def nameFrom[A](tag: WeakTypeTag[A]): String = tag.tpe.typeSymbol.annotations .collectFirst { diff --git a/modules/core/src/main/scala-3/vulcan/CodecCompat.scala b/modules/core/src/main/scala-3/vulcan/CodecCompat.scala index 9a57ea27..e5c951f1 100644 --- a/modules/core/src/main/scala-3/vulcan/CodecCompat.scala +++ b/modules/core/src/main/scala-3/vulcan/CodecCompat.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/Avro.scala b/modules/core/src/main/scala/vulcan/Avro.scala index 1a53c1ac..2a896374 100644 --- a/modules/core/src/main/scala/vulcan/Avro.scala +++ b/modules/core/src/main/scala/vulcan/Avro.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/AvroError.scala b/modules/core/src/main/scala/vulcan/AvroError.scala index ec90af55..8590eeaa 100644 --- a/modules/core/src/main/scala/vulcan/AvroError.scala +++ b/modules/core/src/main/scala/vulcan/AvroError.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/AvroException.scala b/modules/core/src/main/scala/vulcan/AvroException.scala index ceab3bab..6d9b3604 100644 --- a/modules/core/src/main/scala/vulcan/AvroException.scala +++ b/modules/core/src/main/scala/vulcan/AvroException.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/Codec.scala b/modules/core/src/main/scala/vulcan/Codec.scala index 61a33907..c8a49364 100644 --- a/modules/core/src/main/scala/vulcan/Codec.scala +++ b/modules/core/src/main/scala/vulcan/Codec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/Prism.scala b/modules/core/src/main/scala/vulcan/Prism.scala index cb2b58be..bb43d7fa 100644 --- a/modules/core/src/main/scala/vulcan/Prism.scala +++ b/modules/core/src/main/scala/vulcan/Prism.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/Props.scala b/modules/core/src/main/scala/vulcan/Props.scala index 6f8ec0f1..765cc640 100644 --- a/modules/core/src/main/scala/vulcan/Props.scala +++ b/modules/core/src/main/scala/vulcan/Props.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/internal/Deserializer.scala b/modules/core/src/main/scala/vulcan/internal/Deserializer.scala index 2f7722ec..ccfd5576 100644 --- a/modules/core/src/main/scala/vulcan/internal/Deserializer.scala +++ b/modules/core/src/main/scala/vulcan/internal/Deserializer.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/internal/Serializer.scala b/modules/core/src/main/scala/vulcan/internal/Serializer.scala index 62efee02..1e116a30 100644 --- a/modules/core/src/main/scala/vulcan/internal/Serializer.scala +++ b/modules/core/src/main/scala/vulcan/internal/Serializer.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/internal/schema.scala b/modules/core/src/main/scala/vulcan/internal/schema.scala index dfb78230..dbaa9260 100644 --- a/modules/core/src/main/scala/vulcan/internal/schema.scala +++ b/modules/core/src/main/scala/vulcan/internal/schema.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/core/src/main/scala/vulcan/internal/syntax.scala b/modules/core/src/main/scala/vulcan/internal/syntax.scala index 4a16b7b5..91e51855 100644 --- a/modules/core/src/main/scala/vulcan/internal/syntax.scala +++ b/modules/core/src/main/scala/vulcan/internal/syntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/enumeratum/src/main/scala/enumeratum/Vulcan.scala b/modules/enumeratum/src/main/scala/enumeratum/Vulcan.scala index 222e592b..138b43d8 100644 --- a/modules/enumeratum/src/main/scala/enumeratum/Vulcan.scala +++ b/modules/enumeratum/src/main/scala/enumeratum/Vulcan.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/enumeratum/src/main/scala/enumeratum/VulcanEnum.scala b/modules/enumeratum/src/main/scala/enumeratum/VulcanEnum.scala index 7e6a1f86..ffbccbba 100644 --- a/modules/enumeratum/src/main/scala/enumeratum/VulcanEnum.scala +++ b/modules/enumeratum/src/main/scala/enumeratum/VulcanEnum.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/enumeratum/src/main/scala/enumeratum/values/Vulcan.scala b/modules/enumeratum/src/main/scala/enumeratum/values/Vulcan.scala index 0b016d5f..1aff701c 100644 --- a/modules/enumeratum/src/main/scala/enumeratum/values/Vulcan.scala +++ b/modules/enumeratum/src/main/scala/enumeratum/values/Vulcan.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/enumeratum/src/main/scala/enumeratum/values/VulcanValueEnum.scala b/modules/enumeratum/src/main/scala/enumeratum/values/VulcanValueEnum.scala index 6fe793fa..a4afc134 100644 --- a/modules/enumeratum/src/main/scala/enumeratum/values/VulcanValueEnum.scala +++ b/modules/enumeratum/src/main/scala/enumeratum/values/VulcanValueEnum.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/generic/src/main/scala-2/vulcan/generic/package.scala b/modules/generic/src/main/scala-2/vulcan/generic/package.scala index 09274bc2..df77fa48 100644 --- a/modules/generic/src/main/scala-2/vulcan/generic/package.scala +++ b/modules/generic/src/main/scala-2/vulcan/generic/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ @@ -68,7 +68,10 @@ package object generic { .getOrElse(caseClass.typeName.owner), doc = caseClass.annotations.collectFirst { case AvroDoc(doc) => doc - } + }, + aliases = caseClass.annotations.collectFirst { + case AvroAlias(alias) => alias + }.toList ) { (f: Codec.FieldBuilder[A]) => val nullDefaultBase = caseClass.annotations .collectFirst { case AvroNullDefault(enabled) => enabled } @@ -97,6 +100,9 @@ package object generic { doc = param.annotations.collectFirst { case AvroDoc(doc) => doc }, + aliases = param.annotations.collectFirst { + case AvroAlias(alias) => alias + }.toList, default = param.default.orElse( if (codec.schema.exists(_.isNullable) && nullDefaultField) Some(None.asInstanceOf[param.PType]) // TODO: remove cast @@ -149,7 +155,8 @@ package object generic { encode = encode, decode = decode, namespace = namespaceFrom(tag), - doc = docFrom(tag) + doc = docFrom(tag), + aliases = aliasFrom(tag) ) /** @@ -170,6 +177,7 @@ package object generic { encode = encode, decode = decode, namespace = namespaceFrom(tag), - doc = docFrom(tag) + doc = docFrom(tag), + aliases = aliasFrom(tag) ) } diff --git a/modules/generic/src/main/scala-3/vulcan/generic/package.scala b/modules/generic/src/main/scala-3/vulcan/generic/package.scala index 2649d3aa..34ce42a8 100644 --- a/modules/generic/src/main/scala-3/vulcan/generic/package.scala +++ b/modules/generic/src/main/scala-3/vulcan/generic/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ @@ -39,7 +39,10 @@ package object generic { .getOrElse(caseClass.typeInfo.owner), doc = caseClass.annotations.collectFirst { case AvroDoc(doc) => doc - } + }, + aliases = caseClass.annotations.collectFirst { + case AvroAlias(alias) => alias + }.toList ) { (f: Codec.FieldBuilder[A]) => val nullDefaultBase = caseClass.annotations .collectFirst { case AvroNullDefault(enabled) => enabled } @@ -68,6 +71,9 @@ package object generic { doc = param.annotations.collectFirst { case AvroDoc(doc) => doc }, + aliases = param.annotations.collectFirst { + case AvroAlias(alias) => alias + }.toList, default = param.default.orElse( Option.when(codec.schema.exists(_.isNullable) && nullDefaultField)( None.asInstanceOf[param.PType] // TODO: remove cast @@ -112,7 +118,8 @@ package object generic { encode = encode, decode = decode, namespace = namespaceOf[A], - doc = docOf[A] + doc = docOf[A], + aliases = aliasOf[A] ) /** @@ -133,7 +140,8 @@ package object generic { encode = encode, decode = decode, namespace = namespaceOf[A], - doc = docOf[A] + doc = docOf[A], + aliases = aliasOf[A] ) @@ -151,4 +159,9 @@ package object generic { case a: Annotation[AvroDoc, A] => Some(a().doc) case _ => None } + + private inline def aliasOf[A]: Seq[String] = summonFrom { + case a: Annotation[AvroAlias, A] => Seq(a().alias) + case _ => Seq() + } } diff --git a/modules/generic/src/main/scala/vulcan/generic/AvroAlias.scala b/modules/generic/src/main/scala/vulcan/generic/AvroAlias.scala new file mode 100644 index 00000000..7358c6f1 --- /dev/null +++ b/modules/generic/src/main/scala/vulcan/generic/AvroAlias.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2019-2025 OVO Energy Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package vulcan.generic + +import scala.annotation.StaticAnnotation + +/** + * Annotation which can be used to include the record alias + * in derived schemas. + * + * The annotation can be used in the following situations.
+ * - Annotate a type for enum alias when using + * [[deriveEnum]].
+ * - Annotate a type for fixed alias when using + * [[deriveFixed]].
+ * - Annotate a `case class` for record alias + * when using `Codec.derive` from the generic module.
+ * - Annotate a `case class` parameter for record field + * alias when using `Codec.derive` from the + * generic module. + */ +final class AvroAlias(final val alias: String) extends StaticAnnotation { + override final def toString: String = + s"AvroAlias($alias)" +} + +private[vulcan] object AvroAlias { + final def unapply(avroAlias: AvroAlias): Some[String] = + Some(avroAlias.alias) +} diff --git a/modules/generic/src/main/scala/vulcan/generic/AvroDoc.scala b/modules/generic/src/main/scala/vulcan/generic/AvroDoc.scala index fa3a1bd0..8d892cdd 100644 --- a/modules/generic/src/main/scala/vulcan/generic/AvroDoc.scala +++ b/modules/generic/src/main/scala/vulcan/generic/AvroDoc.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/generic/src/main/scala/vulcan/generic/AvroName.scala b/modules/generic/src/main/scala/vulcan/generic/AvroName.scala index 65f22a49..98eb9ff7 100644 --- a/modules/generic/src/main/scala/vulcan/generic/AvroName.scala +++ b/modules/generic/src/main/scala/vulcan/generic/AvroName.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/generic/src/main/scala/vulcan/generic/AvroNamespace.scala b/modules/generic/src/main/scala/vulcan/generic/AvroNamespace.scala index beeaad20..400f6c92 100644 --- a/modules/generic/src/main/scala/vulcan/generic/AvroNamespace.scala +++ b/modules/generic/src/main/scala/vulcan/generic/AvroNamespace.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/generic/src/main/scala/vulcan/generic/AvroNullDefault.scala b/modules/generic/src/main/scala/vulcan/generic/AvroNullDefault.scala index 90f5740e..9b751ac8 100644 --- a/modules/generic/src/main/scala/vulcan/generic/AvroNullDefault.scala +++ b/modules/generic/src/main/scala/vulcan/generic/AvroNullDefault.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/modules/generic/src/test/scala/vulcan/generic/AvroAliasSpec.scala b/modules/generic/src/test/scala/vulcan/generic/AvroAliasSpec.scala new file mode 100644 index 00000000..6ee758aa --- /dev/null +++ b/modules/generic/src/test/scala/vulcan/generic/AvroAliasSpec.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2019-2024 OVO Energy Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package vulcan.generic + +import vulcan.BaseSpec + +final class AvroAliasSpec extends BaseSpec { + describe("AvroAlias") { + it("should provide alias via alias") { + forAll { (s: String) => + assert(new AvroAlias(s).alias == s) + } + } + + it("should include alias in toString") { + forAll { (s: String) => + assert(new AvroAlias(s).toString.contains(s)) + } + } + + it("should provide an extractor for alias") { + forAll { (s1: String) => + assert(new AvroAlias(s1) match { + case AvroAlias(`s1`) => true + case AvroAlias(s2) => fail(s2) + }) + } + } + } +} diff --git a/modules/generic/src/test/scala/vulcan/generic/DerivationSpec.scala b/modules/generic/src/test/scala/vulcan/generic/DerivationSpec.scala index 49a70bae..7eda378c 100644 --- a/modules/generic/src/test/scala/vulcan/generic/DerivationSpec.scala +++ b/modules/generic/src/test/scala/vulcan/generic/DerivationSpec.scala @@ -45,6 +45,12 @@ final class DerivationSpec extends BaseSpec with RoundtripHelpers with CodecSpec } } + it("should use alias annotation") { + assertSchemaIs[FixedAvroAlias] { + """{"type":"fixed","name":"FixedAvroAlias","namespace":"vulcan.generic.examples","size":1,"aliases":["FixedOtherAlias"]}""" + } + } + it("should use namespace annotation") { assertSchemaIs[FixedNamespace] { """{"type":"fixed","name":"FixedNamespace","namespace":"vulcan.generic.examples.overridden","doc":"Some documentation","size":1}""" diff --git a/modules/generic/src/test/scala/vulcan/generic/GenericDerivationCodecSpec.scala b/modules/generic/src/test/scala/vulcan/generic/GenericDerivationCodecSpec.scala index ca0c0c40..c074c5e3 100644 --- a/modules/generic/src/test/scala/vulcan/generic/GenericDerivationCodecSpec.scala +++ b/modules/generic/src/test/scala/vulcan/generic/GenericDerivationCodecSpec.scala @@ -47,6 +47,12 @@ final class GenericDerivationCodecSpec extends CodecBase { } } + it("should support annotation for record alias") { + assertSchemaIs[CaseClassAvroAlias] { + """{"type":"record","name":"CaseClassAvroAlias","namespace":"vulcan.generic.examples","fields":[{"name":"value","type":["null","string"],"aliases":["otherValueAlias"]}],"aliases":["CaseClassOtherAlias"]}""" + } + } + it("should capture errors on invalid names") { assertSchemaError[CaseClassFieldInvalidName] { """org.apache.avro.SchemaParseException: Illegal initial character: -value""" diff --git a/modules/generic/src/test/scala/vulcan/generic/examples/CaseClassAvroAlias.scala b/modules/generic/src/test/scala/vulcan/generic/examples/CaseClassAvroAlias.scala new file mode 100644 index 00000000..731e4719 --- /dev/null +++ b/modules/generic/src/test/scala/vulcan/generic/examples/CaseClassAvroAlias.scala @@ -0,0 +1,20 @@ +/* + * Copyright 2019-2024 OVO Energy Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package vulcan.generic.examples + +import vulcan.Codec +import vulcan.generic._ + +@AvroAlias("CaseClassOtherAlias") +final case class CaseClassAvroAlias( + @AvroAlias("otherValueAlias") + value: Option[String] +) + +object CaseClassAvroAlias { + implicit val codec: Codec[CaseClassAvroAlias] = Codec.derive +} diff --git a/modules/generic/src/test/scala/vulcan/generic/examples/FixedAvroAlias.scala b/modules/generic/src/test/scala/vulcan/generic/examples/FixedAvroAlias.scala new file mode 100644 index 00000000..f72e56e4 --- /dev/null +++ b/modules/generic/src/test/scala/vulcan/generic/examples/FixedAvroAlias.scala @@ -0,0 +1,22 @@ +/* + * Copyright 2019-2024 OVO Energy Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package vulcan.generic.examples + +import vulcan.Codec +import vulcan.generic._ + +@AvroAlias("FixedOtherAlias") +final case class FixedAvroAlias(bytes: Array[Byte]) + +object FixedAvroAlias { + implicit val codec: Codec[FixedAvroAlias] = + deriveFixed( + size = 1, + encode = _.bytes, + decode = bytes => Right(apply(bytes)) + ) +} diff --git a/modules/refined/src/main/scala/vulcan/refined/package.scala b/modules/refined/src/main/scala/vulcan/refined/package.scala index 36fa80aa..172476e4 100644 --- a/modules/refined/src/main/scala/vulcan/refined/package.scala +++ b/modules/refined/src/main/scala/vulcan/refined/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 OVO Energy Limited + * Copyright 2019-2025 OVO Energy Limited * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/project/build.properties b/project/build.properties index 1767a6f8..fe69360b 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.10.5 +sbt.version = 1.10.7 diff --git a/project/plugins.sbt b/project/plugins.sbt index d0b92356..e0a1db6b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.2") addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.1") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.2") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.4")