Skip to content

Commit c0053ec

Browse files
authored
Add EnumTrait validation test (#1679)
1 parent eda264d commit c0053ec

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

smithy-aws-protocol-tests/model/restJson1/validation/malformed-enum.smithy

+43
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,40 @@ apply MalformedEnum @httpMalformedRequestTests([
4848
value: ["ABC", "XYZ"]
4949
}
5050
},
51+
{
52+
id: "RestJsonMalformedEnumTraitString",
53+
documentation: """
54+
When a string member does not contain a valid enum value,
55+
the response should be a 400 ValidationException. Internal-only
56+
enum values are excluded from the response message.""",
57+
protocol: restJson1,
58+
request: {
59+
method: "POST",
60+
uri: "/MalformedEnum",
61+
body: """
62+
{ "stringWithEnumTrait" : $value:S }""",
63+
headers: {
64+
"content-type": "application/json"
65+
}
66+
},
67+
response: {
68+
code: 400,
69+
headers: {
70+
"x-amzn-errortype": "ValidationException"
71+
},
72+
body: {
73+
mediaType: "application/json",
74+
assertion: {
75+
contents: """
76+
{ "message" : "1 validation error detected. Value at '/stringWithEnumTrait' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]",
77+
"fieldList" : [{"message": "Value at '/stringWithEnumTrait' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]", "path": "/stringWithEnumTrait"}]}"""
78+
}
79+
}
80+
},
81+
testParameters: {
82+
value: ["ABC", "XYZ"]
83+
}
84+
},
5185
{
5286
id: "RestJsonMalformedEnumList",
5387
documentation: """
@@ -189,6 +223,8 @@ apply MalformedEnum @httpMalformedRequestTests([
189223
structure MalformedEnumInput {
190224
string: EnumString,
191225

226+
stringWithEnumTrait: EnumTraitString,
227+
192228
list: EnumList,
193229

194230
map: EnumMap,
@@ -207,6 +243,13 @@ enum EnumString {
207243
JKL = "jkl"
208244
}
209245

246+
@enum([
247+
{value: "abc", name: "ABC", tags: ["external"]},
248+
{value: "def", name: "DEF"},
249+
{value: "ghi", name: "GHI", tags: ["internal"]},
250+
])
251+
string EnumTraitString
252+
210253
list EnumList {
211254
member: EnumString
212255
}

0 commit comments

Comments
 (0)