Skip to content

Commit 9ecd7f0

Browse files
authored
Fix consistent service naming and add test coverage (#2349)
* Make service name casing consistent * Add naming-obstacle-course-casing.smithy * Add missing import * Relax obstacle course even further * Better TODO * Add CHANGELOG.next.toml
1 parent f705bde commit 9ecd7f0

File tree

5 files changed

+77
-1
lines changed

5 files changed

+77
-1
lines changed

CHANGELOG.next.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,9 @@ message = "`aws_smithy_types::Error` has been renamed to `aws_smithy_types::erro
192192
references = ["smithy-rs#76", "smithy-rs#2129"]
193193
meta = { "breaking" = true, "tada" = false, "bug" = false }
194194
author = "jdisanti"
195+
196+
[[smithy-rs]]
197+
message = "Fix inconsistent casing in services re-export."
198+
references = ["smithy-rs#2349"]
199+
meta = { "breaking" = false, "tada" = false, "bug" = true, "target" = "server" }
200+
author = "hlbarber"

codegen-client-test/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ val allCodegenTests = "../codegen-core/common-test-models".let { commonModels ->
7979
""".trimIndent(),
8080
imports = listOf("$commonModels/naming-obstacle-course-ops.smithy"),
8181
),
82+
CodegenTest(
83+
"casing#ACRONYMInside_Service",
84+
"naming_test_casing",
85+
imports = listOf("$commonModels/naming-obstacle-course-casing.smithy"),
86+
),
8287
CodegenTest(
8388
"naming_obs_structs#NamingObstacleCourseStructs",
8489
"naming_test_structs",
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
$version: "1.0"
2+
namespace casing
3+
4+
use aws.protocols#awsJson1_1
5+
6+
// TODO(https://github.com/awslabs/smithy-rs/issues/2340): The commented part of the model breaks the generator in a
7+
// miriad of ways. Any solution to the linked issue must address this.
8+
9+
/// Confounds model generation machinery with lots of problematic casing
10+
@awsJson1_1
11+
service ACRONYMInside_Service {
12+
operations: [
13+
DoNothing,
14+
// ACRONYMInside_Op
15+
// ACRONYM_InsideOp
16+
]
17+
}
18+
19+
operation DoNothing {}
20+
21+
// operation ACRONYMInside_Op {
22+
// input: Input,
23+
// output: Output,
24+
// errors: [Error],
25+
// }
26+
27+
// operation ACRONYM_InsideOp {
28+
// input: Input,
29+
// output: Output,
30+
// errors: [Error],
31+
// }
32+
33+
// structure Input {
34+
// ACRONYMInside_Member: ACRONYMInside_Struct,
35+
// ACRONYM_Inside_Member: ACRONYM_InsideStruct,
36+
// ACRONYM_InsideMember: ACRONYMInsideStruct
37+
// }
38+
39+
// structure Output {
40+
// ACRONYMInside_Member: ACRONYMInside_Struct,
41+
// ACRONYM_Inside_Member: ACRONYM_InsideStruct,
42+
// ACRONYM_InsideMember: ACRONYMInsideStruct
43+
// }
44+
45+
// @error("client")
46+
// structure Error {
47+
// ACRONYMInside_Member: ACRONYMInside_Struct,
48+
// ACRONYM_Inside_Member: ACRONYM_InsideStruct,
49+
// ACRONYM_InsideMember: ACRONYMInsideStruct
50+
// }
51+
52+
// structure ACRONYMInside_Struct {
53+
// ACRONYMInside_Member: ACRONYM_InsideStruct,
54+
// ACRONYM_Inside_Member: Integer,
55+
// }
56+
57+
// structure ACRONYM_InsideStruct {
58+
// ACRONYMInside_Member: Integer,
59+
// }
60+
61+
// structure ACRONYMInsideStruct {
62+
// ACRONYMInside_Member: Integer,
63+
// }

codegen-server-test/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies {
3838
val allCodegenTests = "../codegen-core/common-test-models".let { commonModels ->
3939
listOf(
4040
CodegenTest("crate#Config", "naming_test_ops", imports = listOf("$commonModels/naming-obstacle-course-ops.smithy")),
41+
CodegenTest("casing#ACRONYMInside_Service", "naming_test_casing", imports = listOf("$commonModels/naming-obstacle-course-casing.smithy")),
4142
CodegenTest(
4243
"naming_obs_structs#NamingObstacleCourseStructs",
4344
"naming_test_structs",

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust
1717
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate
1818
import software.amazon.smithy.rust.codegen.core.smithy.RustCrate
1919
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport
20+
import software.amazon.smithy.rust.codegen.core.util.toPascalCase
2021
import software.amazon.smithy.rust.codegen.core.util.toSnakeCase
2122
import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency
2223
import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenContext
@@ -42,7 +43,7 @@ open class ServerServiceGenerator(
4243
) {
4344
private val index = TopDownIndex.of(codegenContext.model)
4445
protected val operations = index.getContainedOperations(codegenContext.serviceShape).sortedBy { it.id }
45-
private val serviceName = codegenContext.serviceShape.id.name.toString()
46+
private val serviceName = codegenContext.serviceShape.id.name.toPascalCase()
4647

4748
fun documentation(writer: RustWriter) {
4849
val operations = index.getContainedOperations(codegenContext.serviceShape).toSortedSet(compareBy { it.id })

0 commit comments

Comments
 (0)