Skip to content

Commit

Permalink
fix extra comma
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganesh Jangir committed Oct 7, 2022
1 parent 4f2c3cd commit fa1c4a3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}

0 comments on commit fa1c4a3

Please sign in to comment.