Unverified Commit 9ecd7f0a authored by Harry Barber's avatar Harry Barber Committed by GitHub
Browse files

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
parent f705bde5
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -192,3 +192,9 @@ message = "`aws_smithy_types::Error` has been renamed to `aws_smithy_types::erro
references = ["smithy-rs#76", "smithy-rs#2129"]
meta = { "breaking" = true, "tada" = false, "bug" = false }
author = "jdisanti"

[[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"
+5 −0
Original line number Diff line number Diff line
@@ -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",
+63 −0
Original line number Diff line number Diff line
$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,
// }
+1 −0
Original line number Diff line number Diff line
@@ -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",
+2 −1
Original line number Diff line number Diff line
@@ -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 })