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 02032705792..b003e3c963f 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 @@ -131,11 +131,11 @@ class OperationEndpointResolverMiddleware( param.isRequired -> { when { param.default.isPresent -> { - "config.${param.name.toString().toLowerCamelCase()} ?? ${param.defaultValueLiteral}" + "config.${getBuiltInName(param)} ?? ${param.defaultValueLiteral}" } else -> { // if the parameter is required, we must unwrap the optional value - writer.openBlock("guard let ${param.name.toString().toLowerCamelCase()} = config.${param.name.toString().toLowerCamelCase()} else {", "}") { + writer.openBlock("guard let ${getBuiltInName(param)} = config.${getBuiltInName(param)} else {", "}") { writer.write("throw \$N.unknownError(\"Missing required parameter: \$L\")", SmithyTypes.ClientError, param.name.toString()) } param.name.toString().toLowerCamelCase() @@ -143,10 +143,10 @@ class OperationEndpointResolverMiddleware( } } param.default.isPresent -> { - "config.${param.name.toString().toLowerCamelCase()} ?? ${param.defaultValueLiteral}" + "config.${getBuiltInName(param)} ?? ${param.defaultValueLiteral}" } else -> { - "config.${param.name.toString().toLowerCamelCase()}" + "config.${getBuiltInName(param)}" } } } @@ -156,6 +156,10 @@ class OperationEndpointResolverMiddleware( } } } + + private fun getBuiltInName(param: Parameter): String { + return param.builtIn.get().split("::").last().toLowerCamelCase() + } } private val Parameter.defaultValueLiteral: String