-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when default used with union member target
This NOTE warning makes it clear to modelers that default values on the target shape of a union member are ignored.
- Loading branch information
Showing
3 changed files
with
27 additions
and
0 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
2 changes: 2 additions & 0 deletions
2
...amazon/smithy/model/errorfiles/validators/defaults/warn-when-union-targets-default.errors
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,2 @@ | ||
[NOTE] smithy.example#Example$foo: This union member targets `smithy.api#PrimitiveInteger`, a shape with a default value of `0`. Note that default values are only applicable to structures and ignored in tagged unions. It is a best practice for union members to target shapes with no default value. | Union | ||
[NOTE] smithy.example#Example$bar: This union member targets `smithy.api#PrimitiveBoolean`, a shape with a default value of `false`. Note that default values are only applicable to structures and ignored in tagged unions. It is a best practice for union members to target shapes with no default value. | Union |
10 changes: 10 additions & 0 deletions
10
...amazon/smithy/model/errorfiles/validators/defaults/warn-when-union-targets-default.smithy
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,10 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
union Example { | ||
foo: PrimitiveInteger, // warn | ||
foo2: Integer, // dont' warn | ||
bar: PrimitiveBoolean, // warn | ||
baz: String // don't warn | ||
} |