From b5141084af98d3f19819c3b6e421dea407aa2dac Mon Sep 17 00:00:00 2001 From: Willem Veelenturf Date: Fri, 19 Jul 2024 11:17:57 +0200 Subject: [PATCH] Fix int --- .../wirespec/plugins/pact/GenerateConsumerContractsMojo.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/community/flock/wirespec/plugins/pact/GenerateConsumerContractsMojo.kt b/core/src/main/kotlin/community/flock/wirespec/plugins/pact/GenerateConsumerContractsMojo.kt index 89a16ff..52b2acf 100644 --- a/core/src/main/kotlin/community/flock/wirespec/plugins/pact/GenerateConsumerContractsMojo.kt +++ b/core/src/main/kotlin/community/flock/wirespec/plugins/pact/GenerateConsumerContractsMojo.kt @@ -13,6 +13,7 @@ import community.flock.wirespec.plugin.toDirectory import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonElement +import kotlinx.serialization.json.JsonPrimitive import org.apache.maven.plugins.annotations.Mojo import org.apache.maven.plugins.annotations.Parameter import java.io.File @@ -111,7 +112,10 @@ fun generate( random: Random = kotlin.random.Random.Default, ): JsonElement { if (type is Reference.Primitive) { - TODO("return a primitive") + return when(type.type){ + Reference.Primitive.Type.Integer -> JsonPrimitive(random.nextInt()) + else -> ast.generate(type, random) + } } else { return ast.generate(type, random) }