diff --git a/.changes/5fa3154d-1f42-4b98-9ad1-ef8ef1ad5fbc.json b/.changes/5fa3154d-1f42-4b98-9ad1-ef8ef1ad5fbc.json new file mode 100644 index 00000000000..b91e3ad0670 --- /dev/null +++ b/.changes/5fa3154d-1f42-4b98-9ad1-ef8ef1ad5fbc.json @@ -0,0 +1,8 @@ +{ + "id": "5fa3154d-1f42-4b98-9ad1-ef8ef1ad5fbc", + "type": "feature", + "description": "Improve the coding style of DynamoDB Mapper auto-generated schemas", + "issues": [ + "https://github.com/awslabs/aws-sdk-kotlin/issues/1521" + ] +} \ No newline at end of file diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/annotations/rendering/SchemaRenderer.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/annotations/rendering/SchemaRenderer.kt index 9655c3dccca..6676e004e2f 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/annotations/rendering/SchemaRenderer.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/annotations/rendering/SchemaRenderer.kt @@ -161,7 +161,7 @@ internal class SchemaRenderer( // converter renderValueConverter(prop.type.resolve()) - write("") + write(",") } } @@ -291,7 +291,7 @@ internal class SchemaRenderer( write("@#T", Types.Smithy.ExperimentalApi) withBlock("#Lobject #L : #T {", "}", ctx.attributes.visibility, schemaName, schemaType) { - write("override val converter : #1T = #1T", itemConverter) + write("override val converter: #1T = #1T", itemConverter) write("override val partitionKey: #T = #T(#S)", MapperTypes.Items.keySpec(partitionKeyProp.keySpec), partitionKeyProp.keySpecType, partitionKeyName) if (sortKeyProp != null) { write("override val sortKey: #T = #T(#S)", MapperTypes.Items.keySpec(sortKeyProp.keySpec), sortKeyProp.keySpecType, sortKeyName!!) diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginTest.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginTest.kt index efdf2aa35d6..8b93c38c40a 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginTest.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginTest.kt @@ -106,25 +106,25 @@ class SchemaGeneratorPluginTest { "id", User::id, UserBuilder::id::set, - IntConverter + IntConverter, ), AttributeDescriptor( "fName", User::givenName, UserBuilder::givenName::set, - StringConverter + StringConverter, ), AttributeDescriptor( "lName", User::surname, UserBuilder::surname::set, - StringConverter + StringConverter, ), AttributeDescriptor( "age", User::age, UserBuilder::age::set, - IntConverter + IntConverter, ), ), ) @@ -136,7 +136,7 @@ class SchemaGeneratorPluginTest { schemaContents, """ object UserSchema : ItemSchema.PartitionKey { - override val converter : UserConverter = UserConverter + override val converter: UserConverter = UserConverter override val partitionKey: KeySpec = aws.sdk.kotlin.hll.dynamodbmapper.items.KeySpec.Number("id") } """.trimIndent(), @@ -173,25 +173,25 @@ class SchemaGeneratorPluginTest { "id", BuilderNotRequired::id, BuilderNotRequired::id::set, - IntConverter + IntConverter, ), AttributeDescriptor( "fName", BuilderNotRequired::givenName, BuilderNotRequired::givenName::set, - StringConverter + StringConverter, ), AttributeDescriptor( "lName", BuilderNotRequired::surname, BuilderNotRequired::surname::set, - StringConverter + StringConverter, ), AttributeDescriptor( "age", BuilderNotRequired::age, BuilderNotRequired::age::set, - IntConverter + IntConverter, ), ), ) @@ -414,7 +414,7 @@ class SchemaGeneratorPluginTest { schemaContents, """ public object CustomUserSchema : ItemSchema.PartitionKey { - override val converter : MyCustomUserConverter = MyCustomUserConverter + override val converter: MyCustomUserConverter = MyCustomUserConverter override val partitionKey: KeySpec = aws.sdk.kotlin.hll.dynamodbmapper.items.KeySpec.Number("id") } """.trimIndent(), @@ -570,7 +570,7 @@ class SchemaGeneratorPluginTest { schemaContents, """ object RenamedPartitionKeySchema : ItemSchema.PartitionKey { - override val converter : RenamedPartitionKeyConverter = RenamedPartitionKeyConverter + override val converter: RenamedPartitionKeyConverter = RenamedPartitionKeyConverter override val partitionKey: KeySpec = aws.sdk.kotlin.hll.dynamodbmapper.items.KeySpec.Number("user_id") } """.trimIndent(),