Skip to content
Merged
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
65 changes: 65 additions & 0 deletions codegen/sdk-codegen/aws-models-test/s3/s3-tests.smithy
Original file line number Diff line number Diff line change
@@ -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\"}"
}
}
])
16 changes: 15 additions & 1 deletion codegen/sdk-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AwsService>): 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}",
Expand Down Expand Up @@ -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"
Expand Down