From 2c28a5d217e87dd2020164a050be61815e1324b9 Mon Sep 17 00:00:00 2001 From: Kazik Pogoda Date: Wed, 8 Jan 2025 18:23:15 +0100 Subject: [PATCH] Kotlin code conventions --- .idea/copyright/apache2_0.xml | 2 +- .../kotlin/generator/JsonSchemaGenerator.kt | 38 +++++-------------- .../serialization/JsonSchemaSerializer.kt | 7 +--- src/commonTest/kotlin/JsonSchemaTest.kt | 4 +- .../generator/JsonSchemaGeneratorTest.kt | 20 +--------- src/commonTest/kotlin/test/Money.kt | 6 +-- 6 files changed, 15 insertions(+), 62 deletions(-) diff --git a/.idea/copyright/apache2_0.xml b/.idea/copyright/apache2_0.xml index 82555f1..3e8eec6 100644 --- a/.idea/copyright/apache2_0.xml +++ b/.idea/copyright/apache2_0.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/src/commonMain/kotlin/generator/JsonSchemaGenerator.kt b/src/commonMain/kotlin/generator/JsonSchemaGenerator.kt index 8f7a8e4..23b16e9 100644 --- a/src/commonMain/kotlin/generator/JsonSchemaGenerator.kt +++ b/src/commonMain/kotlin/generator/JsonSchemaGenerator.kt @@ -16,35 +16,15 @@ package com.xemantic.ai.tool.schema.generator -import com.xemantic.ai.tool.schema.ArraySchema -import com.xemantic.ai.tool.schema.BooleanSchema -import com.xemantic.ai.tool.schema.IntegerSchema -import com.xemantic.ai.tool.schema.JsonSchema -import com.xemantic.ai.tool.schema.NumberSchema -import com.xemantic.ai.tool.schema.ObjectSchema -import com.xemantic.ai.tool.schema.StringFormat -import com.xemantic.ai.tool.schema.StringSchema -import com.xemantic.ai.tool.schema.meta.ContentMediaType -import com.xemantic.ai.tool.schema.meta.Description -import com.xemantic.ai.tool.schema.meta.Encoding -import com.xemantic.ai.tool.schema.meta.Format -import com.xemantic.ai.tool.schema.meta.FormatString -import com.xemantic.ai.tool.schema.meta.ItemDescription -import com.xemantic.ai.tool.schema.meta.ItemTitle -import com.xemantic.ai.tool.schema.meta.Max -import com.xemantic.ai.tool.schema.meta.MaxInt -import com.xemantic.ai.tool.schema.meta.MaxItems -import com.xemantic.ai.tool.schema.meta.MaxLength -import com.xemantic.ai.tool.schema.meta.Min -import com.xemantic.ai.tool.schema.meta.MinInt -import com.xemantic.ai.tool.schema.meta.MinItems -import com.xemantic.ai.tool.schema.meta.MinLength -import com.xemantic.ai.tool.schema.meta.Pattern -import com.xemantic.ai.tool.schema.meta.Title -import com.xemantic.ai.tool.schema.meta.UniqueItems -import kotlinx.serialization.* -import kotlinx.serialization.descriptors.* -import kotlin.collections.set +import com.xemantic.ai.tool.schema.* +import com.xemantic.ai.tool.schema.meta.* +import kotlinx.serialization.ExperimentalSerializationApi +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.descriptors.SerialKind +import kotlinx.serialization.descriptors.StructureKind +import kotlinx.serialization.serializer /** * Generates a JSON schema for the specified type [T]. diff --git a/src/commonMain/kotlin/serialization/JsonSchemaSerializer.kt b/src/commonMain/kotlin/serialization/JsonSchemaSerializer.kt index 39b6360..b17b513 100644 --- a/src/commonMain/kotlin/serialization/JsonSchemaSerializer.kt +++ b/src/commonMain/kotlin/serialization/JsonSchemaSerializer.kt @@ -27,12 +27,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.buildSerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonDecoder -import kotlinx.serialization.json.JsonObject -import kotlinx.serialization.json.JsonPrimitive -import kotlinx.serialization.json.buildJsonObject -import kotlinx.serialization.json.jsonObject -import kotlinx.serialization.json.jsonPrimitive +import kotlinx.serialization.json.* public object JsonSchemaSerializer : KSerializer { diff --git a/src/commonTest/kotlin/JsonSchemaTest.kt b/src/commonTest/kotlin/JsonSchemaTest.kt index 6ef2d25..7eeb681 100644 --- a/src/commonTest/kotlin/JsonSchemaTest.kt +++ b/src/commonTest/kotlin/JsonSchemaTest.kt @@ -16,9 +16,9 @@ package com.xemantic.ai.tool.schema -import io.kotest.assertions.json.shouldEqualJson -import com.xemantic.kotlin.test.should import com.xemantic.kotlin.test.have +import com.xemantic.kotlin.test.should +import io.kotest.assertions.json.shouldEqualJson import kotlin.test.Test import kotlin.test.assertFailsWith diff --git a/src/commonTest/kotlin/generator/JsonSchemaGeneratorTest.kt b/src/commonTest/kotlin/generator/JsonSchemaGeneratorTest.kt index 36b8993..705ebc2 100644 --- a/src/commonTest/kotlin/generator/JsonSchemaGeneratorTest.kt +++ b/src/commonTest/kotlin/generator/JsonSchemaGeneratorTest.kt @@ -18,25 +18,7 @@ package com.xemantic.ai.tool.schema.generator import com.xemantic.ai.tool.schema.ContentEncoding import com.xemantic.ai.tool.schema.StringFormat -import com.xemantic.ai.tool.schema.meta.ContentMediaType -import com.xemantic.ai.tool.schema.meta.Description -import com.xemantic.ai.tool.schema.meta.Encoding -import com.xemantic.ai.tool.schema.meta.Format -import com.xemantic.ai.tool.schema.meta.ItemDescription -import com.xemantic.ai.tool.schema.meta.ItemTitle -import com.xemantic.ai.tool.schema.meta.Max -import com.xemantic.ai.tool.schema.meta.MaxInt -import com.xemantic.ai.tool.schema.meta.MaxItems -import com.xemantic.ai.tool.schema.meta.MaxLength -import com.xemantic.ai.tool.schema.meta.Min -import com.xemantic.ai.tool.schema.meta.MinInt -import com.xemantic.ai.tool.schema.meta.MinItems -import com.xemantic.ai.tool.schema.meta.MinLength -import com.xemantic.ai.tool.schema.meta.MultipleOf -import com.xemantic.ai.tool.schema.meta.MultipleOfInt -import com.xemantic.ai.tool.schema.meta.Pattern -import com.xemantic.ai.tool.schema.meta.Title -import com.xemantic.ai.tool.schema.meta.UniqueItems +import com.xemantic.ai.tool.schema.meta.* import com.xemantic.ai.tool.schema.test.BigDecimal import com.xemantic.ai.tool.schema.test.Money import com.xemantic.ai.tool.schema.test.testJson diff --git a/src/commonTest/kotlin/test/Money.kt b/src/commonTest/kotlin/test/Money.kt index 3d2b7e6..2850f40 100644 --- a/src/commonTest/kotlin/test/Money.kt +++ b/src/commonTest/kotlin/test/Money.kt @@ -18,11 +18,7 @@ package com.xemantic.ai.tool.schema.test import com.xemantic.ai.tool.schema.meta.Description import com.xemantic.ai.tool.schema.meta.Pattern -import kotlinx.serialization.ExperimentalSerializationApi -import kotlinx.serialization.InternalSerializationApi -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.Serializer +import kotlinx.serialization.* import kotlinx.serialization.descriptors.PrimitiveKind import kotlinx.serialization.descriptors.buildSerialDescriptor import kotlinx.serialization.encoding.Decoder