@@ -12,6 +12,7 @@ import software.amazon.smithy.kotlin.codegen.core.KotlinWriter
1212import software.amazon.smithy.kotlin.codegen.core.withBlock
1313import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
1414import software.amazon.smithy.kotlin.codegen.model.expectShape
15+ import software.amazon.smithy.kotlin.codegen.utils.toPascalCase
1516import software.amazon.smithy.model.Model
1617import software.amazon.smithy.model.knowledge.TopDownIndex
1718import software.amazon.smithy.model.shapes.OperationShape
@@ -47,7 +48,7 @@ class DslConstantsIntegration : KotlinIntegration {
4748
4849 override fun writeAdditionalFiles (ctx : CodegenContext , delegator : KotlinDelegator ) {
4950 val service = ctx.model.expectShape<ServiceShape >(ctx.settings.service)
50- val serviceName = service.id.name.lowercase( )
51+ val serviceName = getServiceName(ctx.settings.sdkId )
5152
5253 // Get all operations for this service
5354 val operations = TopDownIndex
@@ -63,6 +64,22 @@ class DslConstantsIntegration : KotlinIntegration {
6364 generateOperationConstants(ctx, delegator, serviceName, operations)
6465 }
6566
67+ /* *
68+ * Generate the service name using the same logic as service client generation.
69+ * This ensures consistency between client names (e.g., "LambdaClient") and
70+ * constants names (e.g., "LambdaOperations").
71+ */
72+ private fun getServiceName (sdkId : String ): String {
73+ return sdkId.sanitizeClientName().toPascalCase()
74+ }
75+
76+ /* *
77+ * Sanitize the service name by removing common suffixes, following the same
78+ * logic as the service client naming in KotlinSymbolProvider.
79+ */
80+ private fun String.sanitizeClientName (): String =
81+ replace(Regex (" (API|Client|Service)$" , setOf (RegexOption .IGNORE_CASE )), " " )
82+
6683 /* *
6784 * Generate operation constants for a specific service
6885 */
@@ -72,7 +89,7 @@ class DslConstantsIntegration : KotlinIntegration {
7289 serviceName : String ,
7390 operations : List <OperationShape >
7491 ) {
75- val className = " ${serviceName.replaceFirstChar { it.uppercase() } } Operations"
92+ val className = " ${serviceName} Operations"
7693 val fileName = " $className .kt"
7794
7895 // Generate the file content
0 commit comments