Unverified Commit 565d8383 authored by david-perez's avatar david-perez Committed by GitHub
Browse files

Add miscellaneous protocol test with nested required shape (#1267)

This commit adds another suite of protocol tests to test miscellaneous
aspects of code generation where protocol selection should not be
relevant.

The first test is code-generating an operation with a nested required
shape, minimally reproducing the bug that was fixed in 75056c, so that
we don't regress on it. I've added it to both the `codegen-test` and
`codegen-server-test` subprojects, even though the bug only affected the
server, in part to also incentivize us into adding more tests to this
Smithy model for both clients and servers.
parent 09955d58
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ val allCodegenTests = listOf(
    CodegenTest("com.amazonaws.simple#SimpleService", "simple"),
    CodegenTest("aws.protocoltests.restjson#RestJson", "rest_json"),
    CodegenTest("aws.protocoltests.restjson.validation#RestJsonValidation", "rest_json_validation"),
    CodegenTest("aws.protocoltests.misc#MiscService", "misc"),
    CodegenTest("com.amazonaws.ebs#Ebs", "ebs"),
    CodegenTest("com.amazonaws.s3#AmazonS3", "s3"),
    CodegenTest("com.aws.example#PokemonService", "pokemon_service_sdk")
+1 −0
Original line number Diff line number Diff line
../../codegen-test/model/misc.smithy
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ val allCodegenTests = listOf(
    CodegenTest("aws.protocoltests.json#JsonProtocol", "json_rpc11"),
    CodegenTest("aws.protocoltests.restjson#RestJson", "rest_json"),
    CodegenTest("aws.protocoltests.restjson#RestJsonExtras", "rest_json_extras"),
    CodegenTest("aws.protocoltests.misc#MiscService", "misc"),
    CodegenTest(
        "aws.protocoltests.restxml#RestXml", "rest_xml",
        extraConfig = """, "codegen": { "addMessageToErrors": false } """
+38 −0
Original line number Diff line number Diff line
$version: "1.0"

namespace aws.protocoltests.misc

use aws.protocols#restJson1

/// A service to test miscellaneous aspects of code generation where protocol
/// selection is not relevant. If you want to test something protocol-specific,
/// add it to a separate `<protocol>-extras.smithy`.
@restJson1
@title("MiscService")
service MiscService {
    operations: [
        OperationWithInnerRequiredShape,
    ],
}

/// To not regress on https://github.com/awslabs/smithy-rs/pull/1266
@http(uri: "/operation", method: "GET")
operation OperationWithInnerRequiredShape {
    input: OperationWithInnerRequiredShapeInput,
    output: OperationWithInnerRequiredShapeOutput,
}

structure OperationWithInnerRequiredShapeInput {
    inner: InnerShape
}

structure InnerShape {
    @required
    requiredInnerMostShape: InnermostShape
}

structure InnermostShape {
    aString: String
}

structure OperationWithInnerRequiredShapeOutput { }
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ class StructureGenerator(
    companion object {
        /** Returns whether a structure shape requires a fallible builder to be generated. */
        fun fallibleBuilder(structureShape: StructureShape, symbolProvider: SymbolProvider): Boolean =
            // All inputs should have fallible builders in case a new required field is added in the future
            // All operation inputs should have fallible builders in case a new required field is added in the future.
            structureShape.hasTrait<SyntheticInputTrait>() ||
                structureShape
                    .allMembers