Skip to content

Commit

Permalink
Add restJson1 validation test for uniqueItems missing required keys…
Browse files Browse the repository at this point in the history
… inside lists of objects. (#1735)
  • Loading branch information
pose authored Apr 17, 2023
1 parent 6d413d4 commit f02f5dd
Showing 1 changed file with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,37 @@ apply MalformedUniqueItems @httpMalformedRequestTests([
}
}
},
{
id: "RestJsonMalformedUniqueItemsStructureMissingKeyList",
documentation: """
When a list of structures does not contain required keys,
the response should be a 400 ValidationException and not
a 500 error.""",
protocol: restJson1,
request: {
method: "POST",
uri: "/MalformedUniqueItems",
body: """
{ "structureListWithNoKey" : [{"hi2": "bar"}] }""",
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 '/structureListWithNoKey/0/hi' failed to satisfy constraint: Member must not be null",
"fieldList" : [{"message": "Value at '/structureListWithNoKey/0/hi' failed to satisfy constraint: Member must not be null", "path": "/structureListWithNoKey/0/hi"}]}"""
}
}
}
},
{
id: "RestJsonMalformedUniqueItemsUnionList",
documentation: """
Expand Down Expand Up @@ -491,6 +522,19 @@ apply MalformedUniqueItems @httpMalformedRequestTests([
},
])


string MyStringKey

structure MissingKeyStructure {
@required
hi: MyStringKey
}

@uniqueItems
list StructureSetWithNoKey {
member: MissingKeyStructure
}

structure MalformedUniqueItemsInput {
blobList: BlobSet
booleanList: BooleanSet
Expand All @@ -504,7 +548,8 @@ structure MalformedUniqueItemsInput {
httpDateList: HttpDateSet
enumList: FooEnumSet
intEnumList: IntegerEnumSet
listList: ListSet,
listList: ListSet
structureList: StructureSet
structureListWithNoKey: StructureSetWithNoKey
unionList: UnionSet
}

0 comments on commit f02f5dd

Please sign in to comment.