File tree 3 files changed +39
-3
lines changed
protocol/resources/META-INF/smithy
protocol-tests/test/src/smithy4s/api/validation
3 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,42 @@ object AdtMemberTraitValidatorSpec extends FunSuite {
47
47
success
48
48
}
49
49
50
+ test(" return an error when the union is a mixin" ) {
51
+
52
+ val events = eventsWithoutLocations(
53
+ assembleModel(
54
+ """ $version: "2"
55
+ |namespace test
56
+ |
57
+ |use smithy4s.meta#adtMember
58
+ |
59
+ |@adtMember("test#MyUnion")
60
+ |structure struct {
61
+ | testing: String
62
+ |}
63
+ |
64
+ |@mixin
65
+ |union MyUnion {
66
+ | unionMember: struct
67
+ |}
68
+ |""" .stripMargin
69
+ )
70
+ )
71
+
72
+ val expected =
73
+ ValidationEvent
74
+ .builder()
75
+ .id(" TraitValue" )
76
+ .shapeId(ShapeId .fromParts(" test" , " struct" ))
77
+ .severity(Severity .ERROR )
78
+ .message(
79
+ " Error validating trait `smithy4s.meta#adtMember`: Shape ID `test#MyUnion` does not match selector `union :not([trait|mixin])`"
80
+ )
81
+ .build()
82
+
83
+ assert(events.contains(expected))
84
+ }
85
+
50
86
test(" return error when union does not target the structure" ) {
51
87
val events = eventsWithoutLocations(
52
88
assembleModel(
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ object AdtTraitValidatorSpec extends FunSuite {
52
52
.shapeId(ShapeId .fromParts(" test" , " MyUnion" ))
53
53
.severity(Severity .ERROR )
54
54
.message(
55
- " Trait `smithy4s.meta#adt` cannot be applied to `test#MyUnion`. This trait may only be applied to shapes that match the following selector: :test( union :not([trait|mixin]) )"
55
+ " Trait `smithy4s.meta#adt` cannot be applied to `test#MyUnion`. This trait may only be applied to shapes that match the following selector: union :not([trait|mixin])"
56
56
)
57
57
.build()
58
58
Original file line number Diff line number Diff line change @@ -24,13 +24,13 @@ structure packedInputs {}
24
24
/// which is the default behavior.
25
25
/// Example usage: @adtMember(MyUnion)
26
26
@trait (selector : " structure :not([trait|error])" )
27
- @idRef (failWhenMissing : true , selector : " union" )
27
+ @idRef (failWhenMissing : true , selector : " union :not([trait|mixin]) " )
28
28
string adtMember
29
29
30
30
/// Implies that all members of the union are annotated with the `adtMember` trait.
31
31
/// Further signals that the `sealed trait` for this adt will extend the traits
32
32
/// defined by any mixins that are present on all of the adt members.
33
- @trait (selector : " :test( union :not([trait|mixin]) )" )
33
+ @trait (selector : " union :not([trait|mixin])" )
34
34
structure adt {}
35
35
36
36
// the indexedSeq trait can be added to list shapes in order for the generated collection
You can’t perform that action at this time.
0 commit comments