Loading CHANGELOG.next.toml +6 −0 Original line number Diff line number Diff line Loading @@ -22,3 +22,9 @@ message = "Add support for SSO credentials" references = ["smithy-rs#1051", "aws-sdk-rust#4"] meta = { "breaking" = false, "tada" = true, "bug" = false } author = "rcoh" [[smithy-rs]] message = "Upgraded Smithy to 1.16.1" references = ["smithy-rs#1053"] meta = { "breaking" = false, "tada" = false, "bug" = false } author = "jdisanti" aws/sdk-codegen-test/build.gradle.kts +0 −4 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ plugins { val smithyVersion: String by project dependencies { implementation(project(":aws:sdk-codegen")) implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion") Loading Loading @@ -55,7 +54,6 @@ fun generateSmithyBuild(tests: List<CodegenTest>): String { """ } task("generateSmithyBuild") { description = "generate smithy-build.json" doFirst { Loading @@ -63,7 +61,6 @@ task("generateSmithyBuild") { } } fun generateCargoWorkspace(tests: List<CodegenTest>): String { return """ [workspace] Loading @@ -82,7 +79,6 @@ task("generateCargoWorkspace") { tasks["smithyBuildJar"].dependsOn("generateSmithyBuild") tasks["assemble"].finalizedBy("generateCargoWorkspace") tasks.register<Exec>("cargoCheck") { workingDir("build/smithyprojections/sdk-codegen-test/") // disallow warnings Loading codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +53 −34 Original line number Diff line number Diff line Loading @@ -142,7 +142,8 @@ class ServerProtocolTestGenerator( // This function applies a "fix function" to each broken test before we synthesize it. // Broken tests are those whose definitions in the `awslabs/smithy` repository are wrong, usually because they have // not been written with a server-side perspective in mind. private fun List<TestCase>.fixBroken(): List<TestCase> = this.map { when (it) { private fun List<TestCase>.fixBroken(): List<TestCase> = this.map { when (it) { is TestCase.RequestTest -> { val howToFixIt = BrokenRequestTests[Pair(codegenContext.serviceShape.id.toString(), it.testCase.id)] if (howToFixIt == null) { Loading @@ -155,7 +156,8 @@ class ServerProtocolTestGenerator( is TestCase.ResponseTest -> { it } } } } } private fun renderTestCaseBlock( testCase: HttpMessageTestCase, Loading Loading @@ -431,6 +433,11 @@ class ServerProtocolTestGenerator( private val AwsQuery = "aws.protocoltests.query#AwsQuery" private val Ec2Query = "aws.protocoltests.ec2#AwsEc2" private val ExpectFail = setOf<FailingTest>( FailingTest(RestJson, "RestJsonInputAndOutputWithQuotedStringHeaders", Action.Request), FailingTest(RestJson, "RestJsonInputAndOutputWithQuotedStringHeaders", Action.Response), FailingTest(RestJson, "RestJsonOutputUnionWithUnitMember", Action.Response), FailingTest(RestJson, "RestJsonUnitInputAllowsAccept", Action.Request), FailingTest(RestJson, "RestJsonUnitInputAndOutputNoOutput", Action.Response), FailingTest(RestJson, "RestJsonAllQueryStringTypes", Action.Request), FailingTest(RestJson, "RestJsonQueryStringEscaping", Action.Request), FailingTest(RestJson, "RestJsonSupportsNaNFloatQueryValues", Action.Request), Loading Loading @@ -572,38 +579,50 @@ class ServerProtocolTestGenerator( // to any "expected" value. // Reference: https://doc.rust-lang.org/std/primitive.f32.html // Request for guidance about this test to Smithy team: https://github.com/awslabs/smithy/pull/1040#discussion_r780418707 val params = Node.parse("""{ val params = Node.parse( """ { "queryFloat": "NaN", "queryDouble": "NaN", "queryParamsMapOfStringList": { "Float": ["NaN"], "Double": ["NaN"] } }""".trimIndent()).asObjectNode().get() } """.trimIndent() ).asObjectNode().get() return testCase.toBuilder().params(params).build() } private fun fixRestJsonSupportsInfinityFloatQueryValues(testCase: HttpRequestTestCase): HttpRequestTestCase = testCase.toBuilder().params( Node.parse("""{ Node.parse( """ { "queryFloat": "Infinity", "queryDouble": "Infinity", "queryParamsMapOfStringList": { "Float": ["Infinity"], "Double": ["Infinity"] } }""".trimMargin()).asObjectNode().get() } """.trimMargin() ).asObjectNode().get() ).build() private fun fixRestJsonSupportsNegativeInfinityFloatQueryValues(testCase: HttpRequestTestCase): HttpRequestTestCase = testCase.toBuilder().params( Node.parse("""{ Node.parse( """ { "queryFloat": "-Infinity", "queryDouble": "-Infinity", "queryParamsMapOfStringList": { "Float": ["-Infinity"], "Double": ["-Infinity"] } }""".trimMargin()).asObjectNode().get() } """.trimMargin() ).asObjectNode().get() ).build() // These are tests whose definitions in the `awslabs/smithy` repository are wrong. Loading codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJson.kt +3 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import software.amazon.smithy.rust.codegen.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.smithy.protocols.parse.JsonParserGenerator import software.amazon.smithy.rust.codegen.smithy.protocols.parse.StructuredDataParserGenerator import software.amazon.smithy.rust.codegen.smithy.protocols.restJsonFieldName import software.amazon.smithy.rust.codegen.smithy.protocols.serialize.JsonSerializerGenerator import software.amazon.smithy.rust.codegen.smithy.protocols.serialize.StructuredDataSerializerGenerator Loading Loading @@ -75,11 +76,11 @@ class ServerRestJson(private val codegenContext: CodegenContext) : Protocol { override val defaultTimestampFormat: TimestampFormatTrait.Format = TimestampFormatTrait.Format.EPOCH_SECONDS override fun structuredDataParser(operationShape: OperationShape): StructuredDataParserGenerator { return JsonParserGenerator(codegenContext, httpBindingResolver) return JsonParserGenerator(codegenContext, httpBindingResolver, ::restJsonFieldName) } override fun structuredDataSerializer(operationShape: OperationShape): StructuredDataSerializerGenerator { return JsonSerializerGenerator(codegenContext, httpBindingResolver) return JsonSerializerGenerator(codegenContext, httpBindingResolver, ::restJsonFieldName) } // NOTE: this method is only needed for the little part of client-codegen we use in tests. Loading codegen-test/model/rest-json-extras.smithy +42 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,46 @@ use aws.api#service use smithy.test#httpRequestTests use smithy.test#httpResponseTests // TODO(https://github.com/awslabs/smithy/pull/1049): Remove this once the test case in Smithy is fixed apply InputAndOutputWithHeaders @httpResponseTests([ { id: "FIXED_RestJsonInputAndOutputWithQuotedStringHeaders", documentation: "Tests responses with string list header bindings that require quoting", protocol: restJson1, code: 200, headers: { "X-StringList": "\"b,c\", \"\\\"def\\\"\", a" }, params: { headerStringList: ["b,c", "\"def\"", "a"] } } ]) // TODO(https://github.com/awslabs/smithy/pull/1042): Remove this once the test case in Smithy is fixed apply PostPlayerAction @httpRequestTests([ { id: "FIXED_RestJsonInputUnionWithUnitMember", documentation: "Unit types in unions are serialized like normal structures in requests.", protocol: restJson1, method: "POST", "uri": "/PostPlayerInput", body: """ { "action": { "quit": {} } }""", bodyMediaType: "application/json", headers: {"Content-Type": "application/json"}, params: { action: { quit: {} } } } ]) apply QueryPrecedence @httpRequestTests([ { id: "UrlParamsKeyEncoding", Loading Loading @@ -64,6 +104,8 @@ service RestJsonExtras { NullInNonSparse, CaseInsensitiveErrorOperation, EmptyStructWithContentOnWireOp, // TODO(https://github.com/awslabs/smithy/pull/1042): Remove this once the test case in Smithy is fixed PostPlayerAction ], errors: [ExtraError] } Loading Loading
CHANGELOG.next.toml +6 −0 Original line number Diff line number Diff line Loading @@ -22,3 +22,9 @@ message = "Add support for SSO credentials" references = ["smithy-rs#1051", "aws-sdk-rust#4"] meta = { "breaking" = false, "tada" = true, "bug" = false } author = "rcoh" [[smithy-rs]] message = "Upgraded Smithy to 1.16.1" references = ["smithy-rs#1053"] meta = { "breaking" = false, "tada" = false, "bug" = false } author = "jdisanti"
aws/sdk-codegen-test/build.gradle.kts +0 −4 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ plugins { val smithyVersion: String by project dependencies { implementation(project(":aws:sdk-codegen")) implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion") Loading Loading @@ -55,7 +54,6 @@ fun generateSmithyBuild(tests: List<CodegenTest>): String { """ } task("generateSmithyBuild") { description = "generate smithy-build.json" doFirst { Loading @@ -63,7 +61,6 @@ task("generateSmithyBuild") { } } fun generateCargoWorkspace(tests: List<CodegenTest>): String { return """ [workspace] Loading @@ -82,7 +79,6 @@ task("generateCargoWorkspace") { tasks["smithyBuildJar"].dependsOn("generateSmithyBuild") tasks["assemble"].finalizedBy("generateCargoWorkspace") tasks.register<Exec>("cargoCheck") { workingDir("build/smithyprojections/sdk-codegen-test/") // disallow warnings Loading
codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +53 −34 Original line number Diff line number Diff line Loading @@ -142,7 +142,8 @@ class ServerProtocolTestGenerator( // This function applies a "fix function" to each broken test before we synthesize it. // Broken tests are those whose definitions in the `awslabs/smithy` repository are wrong, usually because they have // not been written with a server-side perspective in mind. private fun List<TestCase>.fixBroken(): List<TestCase> = this.map { when (it) { private fun List<TestCase>.fixBroken(): List<TestCase> = this.map { when (it) { is TestCase.RequestTest -> { val howToFixIt = BrokenRequestTests[Pair(codegenContext.serviceShape.id.toString(), it.testCase.id)] if (howToFixIt == null) { Loading @@ -155,7 +156,8 @@ class ServerProtocolTestGenerator( is TestCase.ResponseTest -> { it } } } } } private fun renderTestCaseBlock( testCase: HttpMessageTestCase, Loading Loading @@ -431,6 +433,11 @@ class ServerProtocolTestGenerator( private val AwsQuery = "aws.protocoltests.query#AwsQuery" private val Ec2Query = "aws.protocoltests.ec2#AwsEc2" private val ExpectFail = setOf<FailingTest>( FailingTest(RestJson, "RestJsonInputAndOutputWithQuotedStringHeaders", Action.Request), FailingTest(RestJson, "RestJsonInputAndOutputWithQuotedStringHeaders", Action.Response), FailingTest(RestJson, "RestJsonOutputUnionWithUnitMember", Action.Response), FailingTest(RestJson, "RestJsonUnitInputAllowsAccept", Action.Request), FailingTest(RestJson, "RestJsonUnitInputAndOutputNoOutput", Action.Response), FailingTest(RestJson, "RestJsonAllQueryStringTypes", Action.Request), FailingTest(RestJson, "RestJsonQueryStringEscaping", Action.Request), FailingTest(RestJson, "RestJsonSupportsNaNFloatQueryValues", Action.Request), Loading Loading @@ -572,38 +579,50 @@ class ServerProtocolTestGenerator( // to any "expected" value. // Reference: https://doc.rust-lang.org/std/primitive.f32.html // Request for guidance about this test to Smithy team: https://github.com/awslabs/smithy/pull/1040#discussion_r780418707 val params = Node.parse("""{ val params = Node.parse( """ { "queryFloat": "NaN", "queryDouble": "NaN", "queryParamsMapOfStringList": { "Float": ["NaN"], "Double": ["NaN"] } }""".trimIndent()).asObjectNode().get() } """.trimIndent() ).asObjectNode().get() return testCase.toBuilder().params(params).build() } private fun fixRestJsonSupportsInfinityFloatQueryValues(testCase: HttpRequestTestCase): HttpRequestTestCase = testCase.toBuilder().params( Node.parse("""{ Node.parse( """ { "queryFloat": "Infinity", "queryDouble": "Infinity", "queryParamsMapOfStringList": { "Float": ["Infinity"], "Double": ["Infinity"] } }""".trimMargin()).asObjectNode().get() } """.trimMargin() ).asObjectNode().get() ).build() private fun fixRestJsonSupportsNegativeInfinityFloatQueryValues(testCase: HttpRequestTestCase): HttpRequestTestCase = testCase.toBuilder().params( Node.parse("""{ Node.parse( """ { "queryFloat": "-Infinity", "queryDouble": "-Infinity", "queryParamsMapOfStringList": { "Float": ["-Infinity"], "Double": ["-Infinity"] } }""".trimMargin()).asObjectNode().get() } """.trimMargin() ).asObjectNode().get() ).build() // These are tests whose definitions in the `awslabs/smithy` repository are wrong. Loading
codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJson.kt +3 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import software.amazon.smithy.rust.codegen.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.smithy.protocols.parse.JsonParserGenerator import software.amazon.smithy.rust.codegen.smithy.protocols.parse.StructuredDataParserGenerator import software.amazon.smithy.rust.codegen.smithy.protocols.restJsonFieldName import software.amazon.smithy.rust.codegen.smithy.protocols.serialize.JsonSerializerGenerator import software.amazon.smithy.rust.codegen.smithy.protocols.serialize.StructuredDataSerializerGenerator Loading Loading @@ -75,11 +76,11 @@ class ServerRestJson(private val codegenContext: CodegenContext) : Protocol { override val defaultTimestampFormat: TimestampFormatTrait.Format = TimestampFormatTrait.Format.EPOCH_SECONDS override fun structuredDataParser(operationShape: OperationShape): StructuredDataParserGenerator { return JsonParserGenerator(codegenContext, httpBindingResolver) return JsonParserGenerator(codegenContext, httpBindingResolver, ::restJsonFieldName) } override fun structuredDataSerializer(operationShape: OperationShape): StructuredDataSerializerGenerator { return JsonSerializerGenerator(codegenContext, httpBindingResolver) return JsonSerializerGenerator(codegenContext, httpBindingResolver, ::restJsonFieldName) } // NOTE: this method is only needed for the little part of client-codegen we use in tests. Loading
codegen-test/model/rest-json-extras.smithy +42 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,46 @@ use aws.api#service use smithy.test#httpRequestTests use smithy.test#httpResponseTests // TODO(https://github.com/awslabs/smithy/pull/1049): Remove this once the test case in Smithy is fixed apply InputAndOutputWithHeaders @httpResponseTests([ { id: "FIXED_RestJsonInputAndOutputWithQuotedStringHeaders", documentation: "Tests responses with string list header bindings that require quoting", protocol: restJson1, code: 200, headers: { "X-StringList": "\"b,c\", \"\\\"def\\\"\", a" }, params: { headerStringList: ["b,c", "\"def\"", "a"] } } ]) // TODO(https://github.com/awslabs/smithy/pull/1042): Remove this once the test case in Smithy is fixed apply PostPlayerAction @httpRequestTests([ { id: "FIXED_RestJsonInputUnionWithUnitMember", documentation: "Unit types in unions are serialized like normal structures in requests.", protocol: restJson1, method: "POST", "uri": "/PostPlayerInput", body: """ { "action": { "quit": {} } }""", bodyMediaType: "application/json", headers: {"Content-Type": "application/json"}, params: { action: { quit: {} } } } ]) apply QueryPrecedence @httpRequestTests([ { id: "UrlParamsKeyEncoding", Loading Loading @@ -64,6 +104,8 @@ service RestJsonExtras { NullInNonSparse, CaseInsensitiveErrorOperation, EmptyStructWithContentOnWireOp, // TODO(https://github.com/awslabs/smithy/pull/1042): Remove this once the test case in Smithy is fixed PostPlayerAction ], errors: [ExtraError] } Loading