Skip to content

Commit 17545f6

Browse files
ysaito1001Zelda Hessler
andauthored
Upgrade Smithy to 1.50.0 (#3728)
## Motivation and Context This PR upgrades Smithy to 1.50.0. The majority of the changes follow `TODO` added in #3690. Other than that, a few adjustments needed to be made: - for the client - added two failing tests `RestJsonClientPopulatesDefaultValuesInInput` and `RestJsonClientUsesExplicitlyProvidedMemberValuesOverDefaults` to known failing tests for the same reason [here](https://github.com/smithy-lang/smithy-rs/blob/main/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolTestGenerator.kt#L72) - added one broken test (i.e. the upstream test definition is incorrect but our implementation is correct) to known broken tests per ([smithy#2341](smithy-lang/smithy#2341), [smithy-rs#3726](#3726 (comment))) - for the server - removed `rest-xml-extras.smithy` since `RestXmlMustSupportParametersInContentType` is now available upstream Smithy 1.50.0 - added the following to known failing tests (since the `awsJson1_0` counterparts are already in the list, but we need the server team to verify this assumption & provide additional `TODO` comments if necessary) - `RestJsonServerPopulatesDefaultsWhenMissingInRequestBody` - `RestJsonServerPopulatesDefaultsInResponseWhenMissingInParams`, - `RestJsonServerPopulatesNestedDefaultValuesWhenMissingInInResponseParams` ## Testing Existing tests in CI ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Zelda Hessler <zhessler@amazon.com>
1 parent 2bf0385 commit 17545f6

File tree

11 files changed

+45
-307
lines changed

11 files changed

+45
-307
lines changed

codegen-client-test/build.gradle.kts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,7 @@ val allCodegenTests = listOf(
6666
ClientTest(
6767
"aws.protocoltests.restjson#RestJsonExtras",
6868
"rest_json_extras",
69-
dependsOn = listOf(
70-
"rest-json-extras.smithy",
71-
// TODO(https://github.com/smithy-lang/smithy/pull/2310): Can be deleted when consumed in next Smithy version.
72-
"rest-json-extras-2310.smithy",
73-
// TODO(https://github.com/smithy-lang/smithy/pull/2314): Can be deleted when consumed in next Smithy version.
74-
"rest-json-extras-2314.smithy",
75-
// TODO(https://github.com/smithy-lang/smithy/pull/2315): Can be deleted when consumed in next Smithy version.
76-
// TODO(https://github.com/smithy-lang/smithy/pull/2331): Can be deleted when consumed in next Smithy version.
77-
"rest-json-extras-2315.smithy",
78-
),
69+
dependsOn = listOf("rest-json-extras.smithy"),
7970
),
8071
ClientTest("aws.protocoltests.misc#MiscService", "misc", dependsOn = listOf("misc.smithy")),
8172
ClientTest("aws.protocoltests.restxml#RestXml", "rest_xml", addMessageToErrors = false),

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolTestGenerator.kt

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package software.amazon.smithy.rust.codegen.client.smithy.generators.protocol
77

8+
import software.amazon.smithy.model.node.NumberNode
89
import software.amazon.smithy.model.shapes.DoubleShape
910
import software.amazon.smithy.model.shapes.FloatShape
1011
import software.amazon.smithy.model.shapes.OperationShape
@@ -27,7 +28,9 @@ import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.Broke
2728
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.FailingTest
2829
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport
2930
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTestGenerator
31+
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId
3032
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId.AWS_JSON_10
33+
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId.REST_JSON
3134
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.TestCase
3235
import software.amazon.smithy.rust.codegen.core.util.PANIC
3336
import software.amazon.smithy.rust.codegen.core.util.dq
@@ -73,7 +76,38 @@ class ClientProtocolTestGenerator(
7376
FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ClientPopulatesDefaultsValuesWhenMissingInResponse"),
7477
FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ClientUsesExplicitlyProvidedMemberValuesOverDefaults"),
7578
FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ClientPopulatesDefaultValuesInInput"),
79+
FailingTest.RequestTest(REST_JSON, "RestJsonClientPopulatesDefaultValuesInInput"),
80+
FailingTest.RequestTest(REST_JSON, "RestJsonClientUsesExplicitlyProvidedMemberValuesOverDefaults"),
7681
)
82+
83+
private val BrokenTests:
84+
Set<BrokenTest> =
85+
setOf(
86+
BrokenTest.ResponseTest(
87+
ServiceShapeId.REST_JSON,
88+
"RestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse",
89+
howToFixItFn = ::fixRestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse,
90+
inAtLeast = setOf("1.50.0"),
91+
trackedIn =
92+
setOf(
93+
// TODO(https://github.com/smithy-lang/smithy/pull/2341)
94+
"https://github.com/smithy-lang/smithy/pull/2341",
95+
),
96+
),
97+
)
98+
99+
private fun fixRestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse(
100+
testCase: TestCase.ResponseTest,
101+
): TestCase.ResponseTest {
102+
val fixedParams =
103+
testCase.testCase.params.toBuilder().withMember("defaultTimestamp", NumberNode.from(2)).build()
104+
return TestCase.ResponseTest(
105+
testCase.testCase.toBuilder()
106+
.params(fixedParams)
107+
.build(),
108+
testCase.targetShape,
109+
)
110+
}
77111
}
78112

79113
override val appliesTo: AppliesTo
@@ -85,7 +119,7 @@ class ClientProtocolTestGenerator(
85119
override val disabledTests: Set<String>
86120
get() = emptySet()
87121
override val brokenTests: Set<BrokenTest>
88-
get() = emptySet()
122+
get() = BrokenTests
89123

90124
override val logger: Logger = Logger.getLogger(javaClass.name)
91125

codegen-core/common-test-models/rest-json-extras-2310.smithy

Lines changed: 0 additions & 35 deletions
This file was deleted.

codegen-core/common-test-models/rest-json-extras-2314.smithy

Lines changed: 0 additions & 39 deletions
This file was deleted.

codegen-core/common-test-models/rest-json-extras-2315.smithy

Lines changed: 0 additions & 133 deletions
This file was deleted.

codegen-core/common-test-models/rest-json-extras.smithy

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ service RestJsonExtras {
6666
CaseInsensitiveErrorOperation,
6767
EmptyStructWithContentOnWireOp,
6868
QueryPrecedence,
69-
// TODO(https://github.com/smithy-lang/smithy/pull/2314)
70-
HttpPayloadTraits2,
71-
// TODO(https://github.com/smithy-lang/smithy/pull/2310)
72-
MalformedContentTypeWithBody2,
73-
// TODO(https://github.com/smithy-lang/smithy/pull/2315)
74-
HttpEnumPayload2,
75-
HttpStringPayload2,
7669
],
7770
errors: [ExtraError]
7871
}

codegen-core/common-test-models/rest-xml-extras.smithy

Lines changed: 0 additions & 53 deletions
This file was deleted.

codegen-server-test/build.gradle.kts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,7 @@ val allCodegenTests = "../codegen-core/common-test-models".let { commonModels ->
6363
CodegenTest(
6464
"aws.protocoltests.restjson#RestJsonExtras",
6565
"rest_json_extras",
66-
imports = listOf(
67-
"$commonModels/rest-json-extras.smithy",
68-
// TODO(https://github.com/smithy-lang/smithy/pull/2310): Can be deleted when consumed in next Smithy version.
69-
"$commonModels/rest-json-extras-2310.smithy",
70-
// TODO(https://github.com/smithy-lang/smithy/pull/2314): Can be deleted when consumed in next Smithy version.
71-
"$commonModels/rest-json-extras-2314.smithy",
72-
// TODO(https://github.com/smithy-lang/smithy/pull/2315): Can be deleted when consumed in next Smithy version.
73-
// TODO(https://github.com/smithy-lang/smithy/pull/2331): Can be deleted when consumed in next Smithy version.
74-
"$commonModels/rest-json-extras-2315.smithy",
75-
),
66+
imports = listOf("$commonModels/rest-json-extras.smithy"),
7667
),
7768
CodegenTest(
7869
"aws.protocoltests.restjson.validation#RestJsonValidation",
@@ -100,11 +91,6 @@ val allCodegenTests = "../codegen-core/common-test-models".let { commonModels ->
10091
"pokemon-service-awsjson-server-sdk",
10192
imports = listOf("$commonModels/pokemon-awsjson.smithy", "$commonModels/pokemon-common.smithy"),
10293
),
103-
CodegenTest(
104-
"aws.protocoltests.restxml#RestXmlExtras",
105-
"rest_xml_extras",
106-
imports = listOf("$commonModels/rest-xml-extras.smithy"),
107-
),
10894
)
10995
}
11096

0 commit comments

Comments
 (0)