diff --git a/.changes/5c7e4dc6-7bf9-421b-a6d9-01007eacf6be.json b/.changes/5c7e4dc6-7bf9-421b-a6d9-01007eacf6be.json new file mode 100644 index 00000000000..c2999bf799b --- /dev/null +++ b/.changes/5c7e4dc6-7bf9-421b-a6d9-01007eacf6be.json @@ -0,0 +1,8 @@ +{ + "id": "5c7e4dc6-7bf9-421b-a6d9-01007eacf6be", + "type": "misc", + "description": "Enable [Explicit API mode](https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md)", + "issues": [ + "awslabs/smithy-kotlin#216" + ] +} \ No newline at end of file diff --git a/aws-runtime/build.gradle.kts b/aws-runtime/build.gradle.kts index bfd90cad864..5cb7a55b3f5 100644 --- a/aws-runtime/build.gradle.kts +++ b/aws-runtime/build.gradle.kts @@ -62,8 +62,7 @@ subprojects { } kotlin { - // TODO - refactor this to error `explicitApi()` - explicitApiWarning() + explicitApi() sourceSets { all { diff --git a/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/PresignerGenerator.kt b/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/PresignerGenerator.kt index 344e8c5be13..a7b8d737863 100644 --- a/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/PresignerGenerator.kt +++ b/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/PresignerGenerator.kt @@ -317,8 +317,10 @@ class PresignerGenerator : KotlinIntegration { writer .addImport(KotlinTypes.Time.Duration) .withBlock( - "suspend fun $requestTypeName.presign(config: $serviceClientTypeName.Config, duration: #T): HttpRequest {", + "public suspend fun #L.presign(config: #L.Config, duration: #T): HttpRequest {", "}\n", + requestTypeName, + serviceClientTypeName, KotlinTypes.Time.Duration ) { withBlock("val presignConfig = $presignConfigTypeName {", "}") { @@ -341,8 +343,9 @@ class PresignerGenerator : KotlinIntegration { writer .addImport(KotlinTypes.Time.Duration) .withBlock( - "suspend fun $requestTypeName.presign(presignConfig: ServicePresignConfig, duration: #T): HttpRequest {", + "public suspend fun #L.presign(presignConfig: ServicePresignConfig, duration: #T): HttpRequest {", "}\n", + requestTypeName, KotlinTypes.Time.Duration ) { write("return createPresignedRequest(presignConfig, $requestConfigFnName(this, duration))") diff --git a/codegen/smithy-aws-kotlin-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/PresignerGeneratorTest.kt b/codegen/smithy-aws-kotlin-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/PresignerGeneratorTest.kt index 4c4942674c6..71014722a3d 100644 --- a/codegen/smithy-aws-kotlin-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/PresignerGeneratorTest.kt +++ b/codegen/smithy-aws-kotlin-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/PresignerGeneratorTest.kt @@ -116,7 +116,7 @@ class PresignerGeneratorTest { * @param duration the amount of time from signing for which the request is valid, with seconds granularity. * @return The [HttpRequest] that can be invoked within the specified time window. */ - suspend fun GetFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest { + public suspend fun GetFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest { return createPresignedRequest(presignConfig, getFooPresignConfig(this, duration)) } @@ -126,7 +126,7 @@ class PresignerGeneratorTest { * @param duration the amount of time from signing for which the request is valid, with seconds granularity. * @return The [HttpRequest] that can be invoked within the specified time window. */ - suspend fun GetFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest { + public suspend fun GetFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest { val presignConfig = TestPresignConfig { credentialsProvider = config.credentialsProvider endpointProvider = config.endpointResolver.asSigningEndpointProvider() @@ -155,7 +155,7 @@ class PresignerGeneratorTest { * @param duration the amount of time from signing for which the request is valid, with seconds granularity. * @return The [HttpRequest] that can be invoked within the specified time window. */ - suspend fun PostFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest { + public suspend fun PostFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest { return createPresignedRequest(presignConfig, postFooPresignConfig(this, duration)) } @@ -165,7 +165,7 @@ class PresignerGeneratorTest { * @param duration the amount of time from signing for which the request is valid, with seconds granularity. * @return The [HttpRequest] that can be invoked within the specified time window. */ - suspend fun PostFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest { + public suspend fun PostFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest { val presignConfig = TestPresignConfig { credentialsProvider = config.credentialsProvider endpointProvider = config.endpointResolver.asSigningEndpointProvider() @@ -194,7 +194,7 @@ class PresignerGeneratorTest { * @param duration the amount of time from signing for which the request is valid, with seconds granularity. * @return The [HttpRequest] that can be invoked within the specified time window. */ - suspend fun PutFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest { + public suspend fun PutFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest { return createPresignedRequest(presignConfig, putFooPresignConfig(this, duration)) } @@ -204,7 +204,7 @@ class PresignerGeneratorTest { * @param duration the amount of time from signing for which the request is valid, with seconds granularity. * @return The [HttpRequest] that can be invoked within the specified time window. */ - suspend fun PutFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest { + public suspend fun PutFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest { val presignConfig = TestPresignConfig { credentialsProvider = config.credentialsProvider endpointProvider = config.endpointResolver.asSigningEndpointProvider() diff --git a/services/build.gradle.kts b/services/build.gradle.kts index 85237d4e155..c39fd0ecc0e 100644 --- a/services/build.gradle.kts +++ b/services/build.gradle.kts @@ -44,6 +44,8 @@ subprojects { } kotlin { + explicitApi() + sourceSets { all { val srcDir = if (name.endsWith("Main")) "src" else "test"