forked from smithy-lang/smithy-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nested server structure member shapes targeting simple shapes with de…
…fault trait (smithy-lang#2352) * Nested server structure member shapes targeting simple shapes with `@default` Signed-off-by: Daniele Ahmed <[email protected]> * Add changelog entry Signed-off-by: Daniele Ahmed <[email protected]> * Update CHANGELOG Signed-off-by: Daniele Ahmed <[email protected]> * Add unit test Signed-off-by: Daniele Ahmed <[email protected]> * Add integration test Signed-off-by: Daniele Ahmed <[email protected]> * Change method Signed-off-by: Daniele Ahmed <[email protected]> * Include comment to describe the test Signed-off-by: Daniele Ahmed <[email protected]> --------- Signed-off-by: Daniele Ahmed <[email protected]>
- Loading branch information
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...zon/smithy/rust/codegen/server/smithy/generators/ServerBuilderConstraintViolationsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.server.smithy.generators | ||
|
||
import org.junit.jupiter.api.Test | ||
import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel | ||
import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverIntegrationTest | ||
|
||
class ServerBuilderConstraintViolationsTest { | ||
|
||
// This test exists not to regress on [this](https://github.com/awslabs/smithy-rs/issues/2343) issue. | ||
// We generated constraint violation variants, pointing to a structure (StructWithInnerDefault below), | ||
// but the structure was not constrained, because the structure's member have a default value | ||
// and default values are validated at generation time from the model. | ||
@Test | ||
fun `it should not generate constraint violations for members with a default value`() { | ||
val model = """ | ||
namespace test | ||
use aws.protocols#restJson1 | ||
use smithy.framework#ValidationException | ||
@restJson1 | ||
service SimpleService { | ||
operations: [Operation] | ||
} | ||
@http(uri: "/operation", method: "POST") | ||
operation Operation { | ||
input: OperationInput | ||
errors: [ValidationException] | ||
} | ||
structure OperationInput { | ||
@required | ||
requiredStructureWithInnerDefault: StructWithInnerDefault | ||
} | ||
structure StructWithInnerDefault { | ||
@default(false) | ||
inner: PrimitiveBoolean | ||
} | ||
""".asSmithyModel(smithyVersion = "2") | ||
serverIntegrationTest(model) | ||
} | ||
} |