From fa1c4a39a1840444abb9b56f144670e6ba6812eb Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Fri, 2 Sep 2022 09:45:14 -0700 Subject: [PATCH] fix extra comma --- .../swift/codegen/EndpointParamsGenerator.kt | 2 +- .../swift/codegen/EndpointTestGenerator.kt | 23 +++++++++++-------- .../middleware/EndpointResolverMiddleware.kt | 2 +- .../OperationEndpointResolverMiddleware.kt | 3 +-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointParamsGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointParamsGenerator.kt index 5c9af339464..ee907d3cd79 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointParamsGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointParamsGenerator.kt @@ -64,7 +64,7 @@ fun Parameter.toSymbol(): Symbol { val swiftType = when (type) { ParameterType.STRING -> SwiftTypes.String ParameterType.BOOLEAN -> SwiftTypes.Bool - else -> throw CodegenException("Unsupported parameter type: ${type}") + else -> throw CodegenException("Unsupported parameter type: $type") } var builder = Symbol.builder().name(swiftType.fullName) if (!isRequired) { diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointTestGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointTestGenerator.kt index 565e75f60c6..9858db400e2 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointTestGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointTestGenerator.kt @@ -40,18 +40,21 @@ class EndpointTestGenerator( writer.write("/// \$L", testCase.documentation) writer.openBlock("func testResolve$idx() throws {", "}") { writer.openBlock("let endpointParams = EndpointParams(", ")") { - testCase.params.members.filter { endpointParamsMembers.contains(it.key.value) } - .toSortedMap(compareBy { it.value }).map { (key, value) -> - key to value - }.forEachIndexed { idx, pair -> - writer.writeInline("${pair.first.value.toCamelCase()}: ") - val value = Value.fromNode(pair.second) - writer.call { - generateValue( - writer, value, if (idx < testCase.params.members.values.count() - 1) "," else "" - ) + val applicableParams = + testCase.params.members.filter { endpointParamsMembers.contains(it.key.value) } + .toSortedMap(compareBy { it.value }).map { (key, value) -> + key to value } + + applicableParams.forEachIndexed { idx, pair -> + writer.writeInline("${pair.first.value.toCamelCase()}: ") + val value = Value.fromNode(pair.second) + writer.call { + generateValue( + writer, value, if (idx < applicableParams.count() - 1) "," else "" + ) } + } } writer.write("let resolver = DefaultEndpointResolver()").write("") diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/EndpointResolverMiddleware.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/EndpointResolverMiddleware.kt index 2aba2c1cc5b..3bb8d5357ca 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/EndpointResolverMiddleware.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/EndpointResolverMiddleware.kt @@ -80,7 +80,7 @@ class EndpointResolverMiddleware( writer.write("var updatedContext = context") .openBlock("if let signingRegion = awsEndpoint.signingRegion {", "}") { writer.write("updatedContext.attributes.set(key: HttpContext.signingRegion, value: signingRegion)") - } + } writer.openBlock("if let signingName = awsEndpoint.signingName {", "}") { writer.write("updatedContext.attributes.set(key: HttpContext.signingName, value: signingName)") }.write("") diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt index c27b0289e19..77b96550436 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt @@ -8,7 +8,6 @@ package software.amazon.smithy.aws.swift.codegen.middleware import software.amazon.smithy.aws.reterminus.EndpointRuleset import software.amazon.smithy.aws.swift.codegen.AWSServiceTypes import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rulesengine.traits.ClientContextParamsTrait import software.amazon.smithy.rulesengine.traits.ContextParamTrait import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait import software.amazon.smithy.rulesengine.traits.StaticContextParamsTrait @@ -72,6 +71,6 @@ class OperationEndpointResolverMiddleware( } writer.write("let endpointParams = EndpointParams(${params.joinToString(separator = ", ")})") val middlewareParamsString = "endpointResolver: config.endpointResolver, endpointParams: endpointParams" - writer.write("$operationStackName.${middlewareStep.stringValue()}.intercept(position: ${position.stringValue()}, middleware: \$N<\$N, \$N>(${middlewareParamsString}))", AWSServiceTypes.EndpointResolverMiddleware, output, outputError) + writer.write("$operationStackName.${middlewareStep.stringValue()}.intercept(position: ${position.stringValue()}, middleware: \$N<\$N, \$N>($middlewareParamsString))", AWSServiceTypes.EndpointResolverMiddleware, output, outputError) } }