diff --git a/core/src/main/scala-2/sttp/tapir/internal/CodecEnumerationMacro.scala b/core/src/main/scala-2/sttp/tapir/internal/CodecEnumerationMacro.scala index 08319b325c..fdb2ca3d6d 100644 --- a/core/src/main/scala-2/sttp/tapir/internal/CodecEnumerationMacro.scala +++ b/core/src/main/scala-2/sttp/tapir/internal/CodecEnumerationMacro.scala @@ -10,7 +10,7 @@ private[tapir] object CodecEnumerationMacro { // this needs to be a macro so that we can call another macro - Validator.derivedEnumeration c.Expr[CreateDerivedEnumerationCodec[L, T]](q""" - new sttp.tapir.macros.CreateDerivedEnumerationCodec(Validator.derivedEnumeration) + new sttp.tapir.macros.CreateDerivedEnumerationCodec(sttp.tapir.Validator.derivedEnumeration) """) } } diff --git a/core/src/test/scala/sttp/tapir/namespacing/SchemaMacroNamespaceTest.scala b/core/src/test/scala/sttp/tapir/namespacing/SchemaMacroNamespaceTest.scala new file mode 100644 index 0000000000..8b00a7906b --- /dev/null +++ b/core/src/test/scala/sttp/tapir/namespacing/SchemaMacroNamespaceTest.scala @@ -0,0 +1,19 @@ +package sttp.tapir.namespacing + +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class SchemaMacroNamespaceTest extends AnyFlatSpec with Matchers { + + // #2254: the macro should reference fully qualified class names + it should "compile macro-generated code using derivedEnumeration in a package other than sttp.tapir" in { + sealed trait MyProduct + object MyProduct { + def fromString(m: String): Option[MyProduct] = ??? + } + case object V1 extends MyProduct + + import sttp.tapir.Codec + Codec.derivedEnumeration[String, MyProduct](MyProduct.fromString, _.toString) + } +}