Skip to content

Commit

Permalink
fix: code gen actual dataref types
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman committed Nov 14, 2023
1 parent a996136 commit c4c6d5a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
)
)
),
)
Expand All @@ -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
/**
Expand All @@ -117,10 +119,11 @@ public data class TestResponse(
public val time: OffsetDateTime,
public val array: ArrayList<String>,
public val nestedArray: ArrayList<ArrayList<String>>,
public val dataRefArray: ArrayList<TestRequest>,
public val map: Map<String, Long>,
public val nestedMap: Map<String, Map<String, Long>>,
public val verbRef: VerbRef,
public val dataRef: DataRef,
public val dataRef: TestRequest,
)
@Ignore
Expand Down

0 comments on commit c4c6d5a

Please sign in to comment.