Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extension Target.Dependency {
static var Smithy: Self { .product(name: "Smithy", package: "smithy-swift") }
static var SmithyAWSJSON: Self { .product(name: "SmithyAWSJSON", package: "smithy-swift") }
static var SmithyRPCv2CBOR: Self { .product(name: "SmithyRPCv2CBOR", package: "smithy-swift") }
static var SmithyRestJSON1: Self { .product(name: "SmithyRestJSON1", package: "smithy-swift") }
static var SmithyCBOR: Self { .product(name: "SmithyCBOR", package: "smithy-swift") }
static var SmithyChecksumsAPI: Self { .product(name: "SmithyChecksumsAPI", package: "smithy-swift") }
static var SmithyChecksums: Self { .product(name: "SmithyChecksums", package: "smithy-swift") }
Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,7 @@ extension Target.Dependency {
static var Smithy: Self { .product(name: "Smithy", package: "smithy-swift") }
static var SmithyAWSJSON: Self { .product(name: "SmithyAWSJSON", package: "smithy-swift") }
static var SmithyRPCv2CBOR: Self { .product(name: "SmithyRPCv2CBOR", package: "smithy-swift") }
static var SmithyRestJSON1: Self { .product(name: "SmithyRestJSON1", package: "smithy-swift") }
static var SmithyCBOR: Self { .product(name: "SmithyCBOR", package: "smithy-swift") }
static var SmithyChecksumsAPI: Self { .product(name: "SmithyChecksumsAPI", package: "smithy-swift") }
static var SmithyChecksums: Self { .product(name: "SmithyChecksums", package: "smithy-swift") }
Expand Down
4 changes: 4 additions & 0 deletions codegen/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ extension Target.Dependency {
static var smithyWaitersAPI: Self { .product(name: "SmithyWaitersAPI", package: "smithy-swift") }
static var smithyTestUtils: Self { .product(name: "SmithyTestUtil", package: "smithy-swift") }
static var smithyStreams: Self { .product(name: "SmithyStreams", package: "smithy-swift") }
static var smithyAWSJSON: Self { .product(name: "SmithyAWSJSON", package: "smithy-swift") }
static var smithyRPCv2CBOR: Self { .product(name: "SmithyRPCv2CBOR", package: "smithy-swift") }
static var smithyRestJSON1: Self { .product(name: "SmithyRestJSON1", package: "smithy-swift") }
}

// MARK: - Base Package
Expand Down Expand Up @@ -108,7 +110,9 @@ private var protocolTestTargets: [Target] {
dependencies: [
.clientRuntime,
.awsClientRuntime,
.smithyAWSJSON,
.smithyRPCv2CBOR,
.smithyRestJSON1,
.smithyRetriesAPI,
.smithyRetries,
.smithy,
Expand Down
13 changes: 8 additions & 5 deletions codegen/protocol-test-codegen-local/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,30 @@ dependencies {
implementation(project(":smithy-aws-swift-codegen"))
}

data class CodegenTest(val service: String, val module: String)
data class CodegenTest(val service: String, val module: String, val forceSchemaBased: Boolean = false)
val codegenTests = listOf(
CodegenTest(
"aws.protocoltests.restjson#RestJsonExtras",
"rest_json_extras"
"rest_json_extras",
forceSchemaBased = true
),
CodegenTest(
"aws.protocoltests.query#AwsQueryExtras",
"AwsQueryExtras"
),
CodegenTest(
"aws.protocoltests.eventstream#TestService",
"EventStream"
"EventStream",
forceSchemaBased = true
),
CodegenTest(
"aws.protocoltests.eventstream#RPCTestService",
"RPCEventStream"
),
CodegenTest(
"aws.endpointtests.stringarray#EndpointStringArray",
"StringArrayEndpointParam"
"StringArrayEndpointParam",
forceSchemaBased = true
)
)

Expand All @@ -74,7 +77,7 @@ fun generateSmithyBuild(tests: List<CodegenTest>): String {
"rootProject": true
},
"mergeModels": true,
"copyrightNotice": "//\n// Copyright Amazon.com Inc. or its affiliates.\n// All Rights Reserved.\n//\n// SPDX-License-Identifier: Apache-2.0\n//\n\n// Code generated by smithy-swift-codegen. DO NOT EDIT!\n\n"
"copyrightNotice": "//\n// Copyright Amazon.com Inc. or its affiliates.\n// All Rights Reserved.\n//\n// SPDX-License-Identifier: Apache-2.0\n//\n\n// Code generated by smithy-swift-codegen. DO NOT EDIT!\n\n"${if (it.forceSchemaBased) ",\n \"forceSchemaBased\": true" else ""}
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions codegen/protocol-test-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ val enabledProtocols = listOf(
ProtocolTest("ec2-query", "aws.protocoltests.ec2#AwsEc2", "Ec2QueryTestSDK"),
ProtocolTest("aws-json-10", "aws.protocoltests.json10#JsonRpc10", "AWSJson10TestSDK"),
ProtocolTest("aws-json-11", "aws.protocoltests.json#JsonProtocol", "AWSJson11TestSDK"),
ProtocolTest("aws-restjson", "aws.protocoltests.restjson#RestJson", "AWSRestJsonTestSDK"),
ProtocolTest("aws-restjson-validation", "aws.protocoltests.restjson.validation#RestJsonValidation", "AWSRestJsonValidationTestSDK"),
ProtocolTest("aws-restjson", "aws.protocoltests.restjson#RestJson", "AWSRestJsonTestSDK", forceSchemaBased = true),
ProtocolTest("aws-restjson-validation", "aws.protocoltests.restjson.validation#RestJsonValidation", "AWSRestJsonValidationTestSDK", forceSchemaBased = true),
ProtocolTest("rest-xml", "aws.protocoltests.restxml#RestXml", "RestXmlTestSDK"),
ProtocolTest("rest-xml-xmlns", "aws.protocoltests.restxml.xmlns#RestXmlWithNamespace", "RestXmlWithNamespaceTestSDK"),
ProtocolTest("aws-query", "aws.protocoltests.query#AwsQuery", "AWSQueryTestSDK"),
Expand All @@ -42,8 +42,8 @@ val enabledProtocols = listOf(
ProtocolTest("smithy-rpcv2-cbor-non-query-compat", "aws.protocoltests.rpcv2cbor#NonQueryCompatibleRpcV2Protocol", "RPCV2CBORTestNonQueryCompatSDK"),

// service specific tests
ProtocolTest("apigateway", "com.amazonaws.apigateway#BackplaneControlService", "APIGatewayTestSDK"),
ProtocolTest("glacier", "com.amazonaws.glacier#Glacier", "GlacierTestSDK"),
ProtocolTest("apigateway", "com.amazonaws.apigateway#BackplaneControlService", "APIGatewayTestSDK", forceSchemaBased = true),
ProtocolTest("glacier", "com.amazonaws.glacier#Glacier", "GlacierTestSDK", forceSchemaBased = true),
ProtocolTest("s3", "com.amazonaws.s3#AmazonS3", "S3TestSDK"),
ProtocolTest("machinelearning", "com.amazonaws.machinelearning#AmazonML_20141212", "MachineLearningTestSDK"),
)
Expand Down Expand Up @@ -83,7 +83,8 @@ enabledProtocols.forEach {

data class ProtocolTest(val projectionName: String,
val serviceShapeId: String,
val moduleName: String) {
val moduleName: String,
val forceSchemaBased: Boolean = false) {
val packageName: String
get() = projectionName.lowercase().filter { it.isLetterOrDigit() }
}
Expand Down Expand Up @@ -118,7 +119,7 @@ fun generateSmithyBuild(tests: List<ProtocolTest>): String {
"sdkId": "${ShapeId.from(test.serviceShapeId).name}",
"swiftVersion": "5.9.0",
"mergeModels": true,
"copyrightNotice": "//\n// Copyright Amazon.com Inc. or its affiliates.\n// All Rights Reserved.\n//\n// SPDX-License-Identifier: Apache-2.0\n//\n\n// Code generated by smithy-swift-codegen. DO NOT EDIT!\n\n"
"copyrightNotice": "//\n// Copyright Amazon.com Inc. or its affiliates.\n// All Rights Reserved.\n//\n// SPDX-License-Identifier: Apache-2.0\n//\n\n// Code generated by smithy-swift-codegen. DO NOT EDIT!\n\n"${if (test.forceSchemaBased) ",\n \"forceSchemaBased\": true" else ""}
}
}
}"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ package software.amazon.smithy.aws.swift.codegen.protocols.restjson

import software.amazon.smithy.aws.swift.codegen.AWSHTTPProtocolCustomizations
import software.amazon.smithy.codegen.core.Symbol
import software.amazon.smithy.swift.codegen.SwiftWriter
import software.amazon.smithy.swift.codegen.swiftmodules.ClientRuntimeTypes
import software.amazon.smithy.swift.codegen.swiftmodules.SmithyRestJson1Types

class RestJSONCustomizations : AWSHTTPProtocolCustomizations() {
class AWSRestJSON1Customizations : AWSHTTPProtocolCustomizations() {
override val baseErrorSymbol: Symbol = ClientRuntimeTypes.RestJSON.RestJSONError

override fun renderClientProtocol(writer: SwiftWriter): String = writer.format("\$N()", SmithyRestJson1Types.HTTPClientProtocol)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import software.amazon.smithy.swift.codegen.aws.protocols.restjson.RestJson1Prot

class AWSRestJson1ProtocolGenerator :
RestJson1ProtocolGenerator(
customizations = RestJSONCustomizations(),
customizations = AWSRestJSON1Customizations(),
operationEndpointResolverMiddlewareFactory = { ctx, sym -> AWSOperationEndpointResolverMiddleware(ctx, sym) },
userAgentMiddlewareFactory = { ctx -> UserAgentMiddleware(ctx.settings) },
serviceErrorProtocolSymbolOverride = AWSClientRuntimeTypes.Core.AWSServiceError,
Expand Down
Loading