diff --git a/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt index 160cd12129..206208dff0 100644 --- a/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt +++ b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt @@ -1,16 +1,7 @@ package xyz.block.ftl.generator -import com.squareup.kotlinpoet.AnnotationSpec -import com.squareup.kotlinpoet.ClassName -import com.squareup.kotlinpoet.FileSpec -import com.squareup.kotlinpoet.FunSpec -import com.squareup.kotlinpoet.KModifier -import com.squareup.kotlinpoet.ParameterSpec +import com.squareup.kotlinpoet.* import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy -import com.squareup.kotlinpoet.PropertySpec -import com.squareup.kotlinpoet.TypeName -import com.squareup.kotlinpoet.TypeSpec -import com.squareup.kotlinpoet.TypeVariableName import xyz.block.ftl.Context import xyz.block.ftl.Ignore import xyz.block.ftl.Ingress @@ -162,7 +153,7 @@ class ModuleGenerator() { } type.verbRef != null -> ClassName("xyz.block.ftl.v1.schema", "VerbRef") - type.dataRef != null -> ClassName("xyz.block.ftl.v1.schema", "DataRef") + type.dataRef != null -> ClassName(type.dataRef.module, type.dataRef.name) else -> throw IllegalArgumentException("Unknown type in kotlin generator") } diff --git a/kotlin-runtime/ftl-generator/src/test/kotlin/xyz/block/ftl/generator/ModuleGeneratorTest.kt b/kotlin-runtime/ftl-generator/src/test/kotlin/xyz/block/ftl/generator/ModuleGeneratorTest.kt index 27e25586d8..2f1aa455d7 100644 --- a/kotlin-runtime/ftl-generator/src/test/kotlin/xyz/block/ftl/generator/ModuleGeneratorTest.kt +++ b/kotlin-runtime/ftl-generator/src/test/kotlin/xyz/block/ftl/generator/ModuleGeneratorTest.kt @@ -51,32 +51,35 @@ public class TestModule() Decl( data_ = Data( comments = listOf("Response comments"), name = "TestResponse", fields = listOf( - Field(name = "int", type = Type(int = Int())), - Field(name = "float", type = Type(float = Float())), - Field(name = "string", type = Type(string = String())), - Field(name = "bool", type = Type(bool = Bool())), - Field(name = "time", type = Type(time = Time())), - Field(name = "array", type = Type(array = Array(element = Type(string = String())))), - Field( - name = "nestedArray", type = Type( - array = Array(element = Type(array = Array(element = Type(string = String())))) + Field(name = "int", type = Type(int = Int())), + Field(name = "float", type = Type(float = Float())), + Field(name = "string", type = Type(string = String())), + Field(name = "bool", type = Type(bool = Bool())), + Field(name = "time", type = Type(time = Time())), + Field(name = "array", type = Type(array = Array(element = Type(string = String())))), + Field( + name = "nestedArray", type = Type( + array = Array(element = Type(array = Array(element = Type(string = String())))) + ) + ), + Field(name = "dataRefArray", type = Type( + array = Array(element = Type(dataRef = DataRef(name = "TestRequest", module = "ftl.test"))) + )), + Field( + name = "map", + type = Type(map = Map(key = Type(string = String()), value_ = Type(int = Int()))) + ), + Field( + name = "nestedMap", type = Type( + map = Map( + key = Type(string = String()), + value_ = Type(map = Map(key = Type(string = String()), value_ = Type(int = Int()))) + ) + ) + ), + Field(name = "verbRef", type = Type(verbRef = VerbRef())), + Field(name = "dataRef", type = Type(dataRef = DataRef(name = "TestRequest", module = "ftl.test"))), ) - ), - Field( - name = "map", - type = Type(map = Map(key = Type(string = String()), value_ = Type(int = Int()))) - ), - Field( - name = "nestedMap", type = Type( - map = Map( - key = Type(string = String()), - value_ = Type(map = Map(key = Type(string = String()), value_ = Type(int = Int()))) - ) - ) - ), - Field(name = "verbRef", type = Type(verbRef = VerbRef())), - Field(name = "dataRef", type = Type(dataRef = DataRef())), - ) ) ), ) @@ -96,7 +99,6 @@ import kotlin.Unit import kotlin.collections.ArrayList import kotlin.collections.Map import xyz.block.ftl.Ignore -import xyz.block.ftl.v1.schema.DataRef import xyz.block.ftl.v1.schema.VerbRef /** @@ -117,10 +119,11 @@ public data class TestResponse( public val time: OffsetDateTime, public val array: ArrayList, public val nestedArray: ArrayList>, + public val dataRefArray: ArrayList, public val map: Map, public val nestedMap: Map>, public val verbRef: VerbRef, - public val dataRef: DataRef, + public val dataRef: TestRequest, ) @Ignore