Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: default trait implementation #927

Merged
merged 10 commits into from
Jun 16, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
import software.amazon.smithy.kotlin.codegen.integration.SectionWriterBinding
import software.amazon.smithy.kotlin.codegen.lang.KotlinTypes
import software.amazon.smithy.kotlin.codegen.model.asNullable
import software.amazon.smithy.kotlin.codegen.model.boxed
import software.amazon.smithy.kotlin.codegen.model.knowledge.AwsSignatureVersion4
import software.amazon.smithy.kotlin.codegen.model.nullable
import software.amazon.smithy.kotlin.codegen.rendering.*
import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigProperty
import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigPropertyType
Expand All @@ -22,7 +22,7 @@ class AwsServiceConfigIntegration : KotlinIntegration {
companion object {
val RegionProp: ConfigProperty = ConfigProperty {
name = "region"
symbol = KotlinTypes.String.toBuilder().boxed().build()
symbol = KotlinTypes.String.toBuilder().nullable().build()
baseClass = AwsRuntimeTypes.Core.Client.AwsSdkClientConfig
useNestedBuilderBaseClass()
documentation = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class EventStreamParserGenerator(
else -> throw CodegenException("unsupported eventHeader shape: member=$hdrBinding; targetShape=$target")
}

val defaultValuePostfix = if (targetSymbol.isNotBoxed && targetSymbol.defaultValue() != null) {
val defaultValuePostfix = if (targetSymbol.isNotNullable && targetSymbol.defaultValue() != null) {
" ?: ${targetSymbol.defaultValue()}"
} else {
""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BoxServicesTest {
structure Other {}

integer NotBoxedField
""".prependNamespaceAndService(operations = listOf("Foo")).toSmithyModel()
""".prependNamespaceAndService(version = "1", operations = listOf("Foo")).toSmithyModel()

val ctx = model.newTestContext()
val transformed = BoxServices().preprocessModel(model, ctx.generationCtx.settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class RemoveEventStreamOperationsTest {
input: BlobInput
}
structure BlobInput {
@required
blob: StreamingBlob
}
@streaming
Expand Down