diff --git a/codegen/sdk-codegen/aws-models-test/s3/s3-tests.smithy b/codegen/sdk-codegen/aws-models-test/s3/s3-tests.smithy new file mode 100644 index 00000000000..898b90fc88b --- /dev/null +++ b/codegen/sdk-codegen/aws-models-test/s3/s3-tests.smithy @@ -0,0 +1,65 @@ +$version: "1.0" + +namespace com.amazonaws.s3 +use smithy.test#httpResponseTests +use smithy.test#httpRequestTests + +apply NotFound @httpResponseTests([ + { + id: "HeadObjectEmptyBody", + documentation: "This test case validates https://github.com/awslabs/aws-sdk-swift/issues/183", + params: { + }, + body: "", + protocol: "aws.protocols#restXml", + code: 404, + headers: { + "x-amz-request-id": "GRZ6BZ468DF52F2E", + "x-amz-id-2": "UTniwu6QmCIjVeuK2ZfeWBOnu7SqMQOS3Vac6B/K4H2ZCawYUl+nDbhGTImuyhZ5DFiojR3Kcz4=", + "content-type": "application/xml", + "date": "Thu, 03 Jun 2021 04:05:52 GMT", + "server": "AmazonS3" + } + } +]) + +// FIXME - when we implement virtual host addressing as the default will need to change the host and uri +// see: https://github.com/awslabs/aws-sdk-kotlin/issues/220 +apply PutObject @httpRequestTests([ + { + id: "PutObjectDefaultContentType", + documentation: "This test case validates default content-type behavior when not specified in the request", + protocol: "aws.protocols#restXml", + method: "PUT", + uri: "/mybucket/mykey", + host: "s3.us-west-2.amazonaws.com", + body: "foobar", + bodyMediaType: "application/octet-stream", + headers: { + "Content-Type": "application/octet-stream" + }, + params: { + Bucket: "mybucket", + Key: "mykey", + Body: "foobar" + } + }, + { + id: "PutOtTbjectExplicitContenype", + documentation: "This test case validates https://github.com/awslabs/aws-sdk-kotlin/issues/193", + protocol: "aws.protocols#restXml", + method: "PUT", + uri: "/mybucket/mykey", + host: "s3.us-west-2.amazonaws.com", + body: "{\"foo\":\"bar\"}", + headers: { + "Content-Type": "application/json" + }, + params: { + Bucket: "mybucket", + Key: "mykey", + ContentType: "application/json", + Body: "{\"foo\":\"bar\"}" + } + } +]) \ No newline at end of file diff --git a/codegen/sdk-codegen/build.gradle.kts b/codegen/sdk-codegen/build.gradle.kts index 1d85b177d80..60d1d52e9cc 100644 --- a/codegen/sdk-codegen/build.gradle.kts +++ b/codegen/sdk-codegen/build.gradle.kts @@ -78,13 +78,21 @@ data class AwsService( // The generated smithy-build.json file is not committed to git since // it's rebuilt each time codegen is performed. fun generateSmithyBuild(services: List): String { + require(services.isNotEmpty()) { + "No services discovered. Verify aws.services and aws.protocols properties in local.build. Aborting." + } val buildStandaloneSdk = getProperty("buildStandaloneSdk")?.toBoolean() ?: false val projections = services.joinToString(",") { service -> // escape windows paths for valid json val absModelPath = service.modelFile.absolutePath.replace("\\", "\\\\") + val importPaths = mutableListOf(absModelPath) + if (file(service.modelExtrasDir).exists()) { + importPaths.add(service.modelExtrasDir.replace("\\", "\\\\")) + } + val imports = importPaths.joinToString { "\"$it\"" } """ "${service.projectionName}": { - "imports": ["$absModelPath"], + "imports": [$imports], "plugins": { "swift-codegen": { "service": "${service.name}", @@ -168,6 +176,12 @@ val AwsService.destinationDir: String return rootProject.file("release").absolutePath } +val AwsService.modelExtrasDir: String + get() { + val sanitizedName = projectionName.split(".")[0] + return rootProject.file("codegen/sdk-codegen/aws-models-test/${sanitizedName}").absolutePath + } + task("stageSdks") { group = "codegen" description = "relocate generated SDK(s) from build directory to release dir"