From 742a80fc1f4214164af5ae05b7ea0dbd389f7fcb Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Mon, 18 Oct 2021 16:02:38 -0400 Subject: [PATCH 1/4] chore: upgrade smithy to 1.12; apply transform for new service errors --- gradle.properties | 2 +- .../amazon/smithy/kotlin/codegen/CodegenVisitor.kt | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 68e591e28..b7aff9510 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,7 @@ ktorVersion=1.6.3 atomicFuVersion=0.16.1 # codegen -smithyVersion=1.9.1 +smithyVersion=1.12.0 smithyGradleVersion=0.5.3 # testing/utility diff --git a/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/CodegenVisitor.kt b/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/CodegenVisitor.kt index 30ee1d0c9..b38639cc8 100644 --- a/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/CodegenVisitor.kt +++ b/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/CodegenVisitor.kt @@ -55,11 +55,19 @@ class CodegenVisitor(context: PluginContext) : ShapeVisitor.Default() { .toList() LOGGER.info("Preprocessing model") + // Model pre-processing: + // 1. Start with the model from the plugin context + // 2. Apply integrations + // 3. Flatten error shapes (see: https://github.com/awslabs/smithy/pull/919) + // 4. Normalize the operations var resolvedModel = context.model for (integration in integrations) { resolvedModel = integration.preprocessModel(resolvedModel, settings) } + resolvedModel = ModelTransformer.create() + .copyServiceErrorsToOperations(resolvedModel, settings.getService(resolvedModel)) + // normalize operations model = OperationNormalizer.transform(resolvedModel, settings.service) From 86924acd0f5a75782ebe7548f1b4d7ef35094ba7 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Mon, 18 Oct 2021 16:44:16 -0400 Subject: [PATCH 2/4] test(rt): add new test for whitespace in xml elements --- .../kotlin/runtime/serde/xml/XmlStreamReaderTest.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/runtime/serde/serde-xml/common/test/aws/smithy/kotlin/runtime/serde/xml/XmlStreamReaderTest.kt b/runtime/serde/serde-xml/common/test/aws/smithy/kotlin/runtime/serde/xml/XmlStreamReaderTest.kt index c4c1c622e..aae2442a1 100644 --- a/runtime/serde/serde-xml/common/test/aws/smithy/kotlin/runtime/serde/xml/XmlStreamReaderTest.kt +++ b/runtime/serde/serde-xml/common/test/aws/smithy/kotlin/runtime/serde/xml/XmlStreamReaderTest.kt @@ -129,6 +129,19 @@ class XmlStreamReaderTest { assertEquals(expected, actual) } + @Test + fun itHandlesWhitespaceValues() = runSuspendTest { + val payload = """ """.encodeToByteArray() + val actual = xmlStreamReader(payload).allTokens() + val expected = listOf( + XmlToken.BeginElement(1, "string"), + XmlToken.Text(1, " "), + XmlToken.EndElement(1, "string"), + ) + + assertEquals(expected, actual) + } + @Test fun kitchenSink() = runSuspendTest { val payload = """ From 86cac633fbbe0c97e909c2cafb63fb483c24b21d Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Mon, 1 Nov 2021 11:32:10 -0400 Subject: [PATCH 3/4] upgrade to smithy 1.13 and fix sdk-version.txt to regenerate when props change --- gradle.properties | 2 +- smithy-kotlin-codegen/build.gradle.kts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b7aff9510..ecba75041 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,7 @@ ktorVersion=1.6.3 atomicFuVersion=0.16.1 # codegen -smithyVersion=1.12.0 +smithyVersion=1.13.0 smithyGradleVersion=0.5.3 # testing/utility diff --git a/smithy-kotlin-codegen/build.gradle.kts b/smithy-kotlin-codegen/build.gradle.kts index 1ae7d5ddb..d2d9c2a8c 100644 --- a/smithy-kotlin-codegen/build.gradle.kts +++ b/smithy-kotlin-codegen/build.gradle.kts @@ -42,6 +42,8 @@ val generateSdkRuntimeVersion by tasks.registering { // this keeps us from having to manually change version numbers in multiple places val resourcesDir = "$buildDir/resources/main/software/amazon/smithy/kotlin/codegen/core" val versionFile = file("$resourcesDir/sdk-version.txt") + val gradlePropertiesFile = rootProject.file("gradle.properties") + inputs.file(gradlePropertiesFile) outputs.file(versionFile) sourceSets.main.get().output.dir(resourcesDir) doLast { From 71e10eae7a605d35140f370d646d4b024fba97de Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Mon, 1 Nov 2021 11:37:27 -0400 Subject: [PATCH 4/4] remove xml test, will be implemented later --- .../kotlin/runtime/serde/xml/XmlStreamReaderTest.kt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/runtime/serde/serde-xml/common/test/aws/smithy/kotlin/runtime/serde/xml/XmlStreamReaderTest.kt b/runtime/serde/serde-xml/common/test/aws/smithy/kotlin/runtime/serde/xml/XmlStreamReaderTest.kt index aae2442a1..c4c1c622e 100644 --- a/runtime/serde/serde-xml/common/test/aws/smithy/kotlin/runtime/serde/xml/XmlStreamReaderTest.kt +++ b/runtime/serde/serde-xml/common/test/aws/smithy/kotlin/runtime/serde/xml/XmlStreamReaderTest.kt @@ -129,19 +129,6 @@ class XmlStreamReaderTest { assertEquals(expected, actual) } - @Test - fun itHandlesWhitespaceValues() = runSuspendTest { - val payload = """ """.encodeToByteArray() - val actual = xmlStreamReader(payload).allTokens() - val expected = listOf( - XmlToken.BeginElement(1, "string"), - XmlToken.Text(1, " "), - XmlToken.EndElement(1, "string"), - ) - - assertEquals(expected, actual) - } - @Test fun kitchenSink() = runSuspendTest { val payload = """