diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index f7915b8265..3ba80588b0 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -28,3 +28,9 @@ message = "Adds jitter to `LazyCredentialsCache`. This allows credentials with t references = ["smithy-rs#2335"] meta = { "breaking" = false, "tada" = false, "bug" = false } author = "ysaito1001" + +[[smithy-rs]] +message = "Fix inconsistent casing in services re-export." +references = ["smithy-rs#2349"] +meta = { "breaking" = false, "tada" = false, "bug" = true, "target" = "server" } +author = "hlbarber" diff --git a/codegen-client-test/build.gradle.kts b/codegen-client-test/build.gradle.kts index 434bcef65f..f3796a6911 100644 --- a/codegen-client-test/build.gradle.kts +++ b/codegen-client-test/build.gradle.kts @@ -79,6 +79,11 @@ val allCodegenTests = "../codegen-core/common-test-models".let { commonModels -> """.trimIndent(), imports = listOf("$commonModels/naming-obstacle-course-ops.smithy"), ), + CodegenTest( + "casing#ACRONYMInside_Service", + "naming_test_casing", + imports = listOf("$commonModels/naming-obstacle-course-casing.smithy"), + ), CodegenTest( "naming_obs_structs#NamingObstacleCourseStructs", "naming_test_structs", diff --git a/codegen-core/common-test-models/naming-obstacle-course-casing.smithy b/codegen-core/common-test-models/naming-obstacle-course-casing.smithy new file mode 100644 index 0000000000..fb80a46d48 --- /dev/null +++ b/codegen-core/common-test-models/naming-obstacle-course-casing.smithy @@ -0,0 +1,63 @@ +$version: "1.0" +namespace casing + +use aws.protocols#awsJson1_1 + +// TODO(https://github.com/awslabs/smithy-rs/issues/2340): The commented part of the model breaks the generator in a +// miriad of ways. Any solution to the linked issue must address this. + +/// Confounds model generation machinery with lots of problematic casing +@awsJson1_1 +service ACRONYMInside_Service { + operations: [ + DoNothing, + // ACRONYMInside_Op + // ACRONYM_InsideOp + ] +} + +operation DoNothing {} + +// operation ACRONYMInside_Op { +// input: Input, +// output: Output, +// errors: [Error], +// } + +// operation ACRONYM_InsideOp { +// input: Input, +// output: Output, +// errors: [Error], +// } + +// structure Input { +// ACRONYMInside_Member: ACRONYMInside_Struct, +// ACRONYM_Inside_Member: ACRONYM_InsideStruct, +// ACRONYM_InsideMember: ACRONYMInsideStruct +// } + +// structure Output { +// ACRONYMInside_Member: ACRONYMInside_Struct, +// ACRONYM_Inside_Member: ACRONYM_InsideStruct, +// ACRONYM_InsideMember: ACRONYMInsideStruct +// } + +// @error("client") +// structure Error { +// ACRONYMInside_Member: ACRONYMInside_Struct, +// ACRONYM_Inside_Member: ACRONYM_InsideStruct, +// ACRONYM_InsideMember: ACRONYMInsideStruct +// } + +// structure ACRONYMInside_Struct { +// ACRONYMInside_Member: ACRONYM_InsideStruct, +// ACRONYM_Inside_Member: Integer, +// } + +// structure ACRONYM_InsideStruct { +// ACRONYMInside_Member: Integer, +// } + +// structure ACRONYMInsideStruct { +// ACRONYMInside_Member: Integer, +// } diff --git a/codegen-server-test/build.gradle.kts b/codegen-server-test/build.gradle.kts index b2841452c1..d8ec164a40 100644 --- a/codegen-server-test/build.gradle.kts +++ b/codegen-server-test/build.gradle.kts @@ -38,6 +38,7 @@ dependencies { val allCodegenTests = "../codegen-core/common-test-models".let { commonModels -> listOf( CodegenTest("crate#Config", "naming_test_ops", imports = listOf("$commonModels/naming-obstacle-course-ops.smithy")), + CodegenTest("casing#ACRONYMInside_Service", "naming_test_casing", imports = listOf("$commonModels/naming-obstacle-course-casing.smithy")), CodegenTest( "naming_obs_structs#NamingObstacleCourseStructs", "naming_test_structs", diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt index baf10e8b4b..fc7e2cdd8b 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt @@ -17,6 +17,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.util.toPascalCase import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenContext @@ -42,7 +43,7 @@ open class ServerServiceGenerator( ) { private val index = TopDownIndex.of(codegenContext.model) protected val operations = index.getContainedOperations(codegenContext.serviceShape).sortedBy { it.id } - private val serviceName = codegenContext.serviceShape.id.name.toString() + private val serviceName = codegenContext.serviceShape.id.name.toPascalCase() fun documentation(writer: RustWriter) { val operations = index.getContainedOperations(codegenContext.serviceShape).toSortedSet(compareBy { it.id })