Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EnumTrait validation test #1679

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,40 @@ apply MalformedEnum @httpMalformedRequestTests([
value: ["ABC", "XYZ"]
}
},
{
id: "RestJsonMalformedEnumTraitString",
documentation: """
When a string member does not contain a valid enum value,
the response should be a 400 ValidationException. Internal-only
enum values are excluded from the response message.""",
protocol: restJson1,
request: {
method: "POST",
uri: "/MalformedEnum",
body: """
{ "stringWithEnumTrait" : $value:S }""",
headers: {
"content-type": "application/json"
}
},
response: {
code: 400,
headers: {
"x-amzn-errortype": "ValidationException"
},
body: {
mediaType: "application/json",
assertion: {
contents: """
{ "message" : "1 validation error detected. Value at '/stringWithEnumTrait' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]",
"fieldList" : [{"message": "Value at '/stringWithEnumTrait' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]", "path": "/stringWithEnumTrait"}]}"""
}
}
},
testParameters: {
value: ["ABC", "XYZ"]
}
},
{
id: "RestJsonMalformedEnumList",
documentation: """
Expand Down Expand Up @@ -189,6 +223,8 @@ apply MalformedEnum @httpMalformedRequestTests([
structure MalformedEnumInput {
string: EnumString,

stringWithEnumTrait: EnumTraitString,

list: EnumList,

map: EnumMap,
Expand All @@ -207,6 +243,13 @@ enum EnumString {
JKL = "jkl"
}

@enum([
{value: "abc", name: "ABC", tags: ["external"]},
{value: "def", name: "DEF"},
{value: "ghi", name: "GHI", tags: ["internal"]},
])
string EnumTraitString

list EnumList {
member: EnumString
}
Expand Down