Skip to content
Closed
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
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ include(":tests:e2e-test-util")
include(":tests:codegen:smoke-tests")
include(":tests:codegen:smoke-tests:services")
include(":tests:codegen:checksums")
include(":tests:codegen:union-example")

// generated services
val File.isServiceDir: Boolean
Expand Down
37 changes: 37 additions & 0 deletions tests/codegen/union-example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import aws.sdk.kotlin.gradle.codegen.dsl.smithyKotlinPlugin
import aws.sdk.kotlin.gradle.codegen.smithyKotlinProjectionSrcDir
import aws.sdk.kotlin.tests.codegen.CodegenTest
import aws.sdk.kotlin.tests.codegen.Model

description = "AWS SDK for Kotlin's union codegen test suite"

val tests = listOf(
CodegenTest("unions", Model("unions.smithy"), "aws.sdk.kotlin.test#TestService"),
)

smithyBuild {
this@Build_gradle.tests.forEach { test ->
projections.register(test.name) {
imports = listOf(layout.projectDirectory.file(test.model.path + test.model.fileName).asFile.absolutePath)
smithyKotlinPlugin {
serviceShapeId = test.serviceShapeId
packageName = "aws.sdk.kotlin.test.${test.name.lowercase()}"
packageVersion = "1.0"
buildSettings {
generateFullProject = false
generateDefaultBuildFiles = false
optInAnnotations = listOf(
"aws.smithy.kotlin.runtime.InternalApi",
"aws.sdk.kotlin.runtime.InternalSdkApi",
)
}
}
}
}
}

kotlin.sourceSets.getByName("test") {
smithyBuild.projections.forEach {
kotlin.srcDir(smithyBuild.smithyKotlinProjectionSrcDir(it.name))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package aws.sdk.kotlin.tests.codegen.unionexample

import aws.sdk.kotlin.test.unions.model.Foo
import kotlin.test.Test

class UnionTest {
@Test
fun `try code generating a union with a member that has the same name as it, then use it`() {
Foo.Foo(true).asFoo()
}
}
26 changes: 26 additions & 0 deletions tests/codegen/union-example/src/test/resources/unions.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$version: "2"
namespace aws.sdk.kotlin.test

use aws.protocols#awsJson1_0
use smithy.rules#operationContextParams
use smithy.rules#endpointRuleSet
use aws.api#service

@awsJson1_0
@service(sdkId: "UnionOperationTest")
service TestService {
operations: [DeleteObjects],
version: "1"
}

operation DeleteObjects {
input: DeleteObjectsRequest
}

structure DeleteObjectsRequest {
Delete: Foo
}

union Foo {
foo: Boolean
}
Loading