Skip to content

Commit 5ea3c40

Browse files
authored
Add tests to verify that type is ignored in union types during deserialization (#4457)
1 parent c13710d commit 5ea3c40

File tree

3 files changed

+197
-2
lines changed

3 files changed

+197
-2
lines changed

test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-core-output.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,4 +702,23 @@
702702
}
703703
}
704704
}
705+
,
706+
{
707+
"description": "Ignores an unrecognized __type property",
708+
"given": {
709+
"response": {
710+
"status_code": 200,
711+
"body": "{\"UnionMember\": {\"StringMember\":\"foobar\", \"__type\": \"aws.protocoltests.json10#MyUnion\"}}"
712+
}
713+
},
714+
"when": {
715+
"action": "unmarshall",
716+
"operation": "AllTypes"
717+
},
718+
"then": {
719+
"deserializedAs": {
720+
"UnionMember": {"StringMember":"foobar"}
721+
}
722+
}
723+
}
705724
]

test/protocol-tests/src/main/resources/codegen-resources/awsjson/service-2.json

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
"MapOfEnumToEnum":{"shape":"MapOfEnumToEnum"},
9595
"ListOfTimeStamp":{"shape":"ListOfTimeStamp"},
9696
"MapOfTimeStamp":{"shape":"MapOfTimeStamp"},
97-
"MyDocument":{"shape":"MyDocument"}
97+
"MyDocument":{"shape":"MyDocument"},
98+
"UnionMember":{"shape":"AllTypesUnionStructure"}
9899
}
99100
},
100101
"BaseType":{
@@ -314,6 +315,93 @@
314315
"MyDocument": {
315316
"type": "structure",
316317
"document": true
318+
},
319+
"AllTypesUnionStructure": {
320+
"type": "structure",
321+
"union": true,
322+
"members": {
323+
"StringMember": {
324+
"shape": "String"
325+
},
326+
"IntegerMember": {
327+
"shape": "Integer"
328+
},
329+
"BooleanMember": {
330+
"shape": "Boolean"
331+
},
332+
"FloatMember": {
333+
"shape": "Float"
334+
},
335+
"DoubleMember": {
336+
"shape": "Double"
337+
},
338+
"LongMember": {
339+
"shape": "Long"
340+
},
341+
"ShortMember": {
342+
"shape": "Short"
343+
},
344+
"EnumMember": {
345+
"shape": "EnumType"
346+
},
347+
"SimpleList": {
348+
"shape": "ListOfStrings"
349+
},
350+
"ListOfEnums": {
351+
"shape": "ListOfEnums"
352+
},
353+
"ListOfMaps": {
354+
"shape": "ListOfMapStringToString"
355+
},
356+
"ListOfStructs": {
357+
"shape": "ListOfSimpleStructs"
358+
},
359+
"MapOfStringToIntegerList": {
360+
"shape": "MapOfStringToIntegerList"
361+
},
362+
"MapOfStringToString": {
363+
"shape": "MapOfStringToString"
364+
},
365+
"MapOfStringToStruct": {
366+
"shape": "MapOfStringToSimpleStruct"
367+
},
368+
"MapOfEnumToEnum": {
369+
"shape": "MapOfEnumToEnum"
370+
},
371+
"TimestampMember": {
372+
"shape": "Timestamp"
373+
},
374+
"StructWithNestedTimestampMember": {
375+
"shape": "StructWithTimestamp"
376+
},
377+
"BlobArg": {
378+
"shape": "BlobType"
379+
},
380+
"StructWithNestedBlob": {
381+
"shape": "StructWithNestedBlobType"
382+
},
383+
"BlobMap": {
384+
"shape": "BlobMapType"
385+
},
386+
"ListOfBlobs": {
387+
"shape": "ListOfBlobsType"
388+
},
389+
"RecursiveStruct": {
390+
"shape": "RecursiveStructType"
391+
},
392+
"PolymorphicTypeWithSubTypes": {
393+
"shape": "BaseType"
394+
},
395+
"PolymorphicTypeWithoutSubTypes": {
396+
"shape": "SubTypeOne"
397+
},
398+
"SetPrefixedMember": {
399+
"shape": "String"
400+
},
401+
"UnionMember": {
402+
"shape": "AllTypesUnionStructure"
403+
}
404+
}
317405
}
318406
}
319407
}

test/protocol-tests/src/main/resources/codegen-resources/restjson/service-2.json

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@
281281
"MapOfEnumToEnum":{"shape":"MapOfEnumToEnum"},
282282
"ListOfTimeStamp":{"shape":"ListOfTimeStamp"},
283283
"MapOfTimeStamp":{"shape":"MapOfTimeStamp"},
284-
"MyDocument":{"shape":"MyDocument"}
284+
"MyDocument":{"shape":"MyDocument"},
285+
"UnionMember":{"shape":"AllTypesUnionStructure"}
285286
}
286287
},
287288
"BaseType":{
@@ -953,6 +954,93 @@
953954
"members":{
954955
"DocumentMember":{"shape":"MyDocument"}
955956
}
957+
},
958+
"AllTypesUnionStructure": {
959+
"type": "structure",
960+
"union": true,
961+
"members": {
962+
"StringMember": {
963+
"shape": "String"
964+
},
965+
"IntegerMember": {
966+
"shape": "Integer"
967+
},
968+
"BooleanMember": {
969+
"shape": "Boolean"
970+
},
971+
"FloatMember": {
972+
"shape": "Float"
973+
},
974+
"DoubleMember": {
975+
"shape": "Double"
976+
},
977+
"LongMember": {
978+
"shape": "Long"
979+
},
980+
"ShortMember": {
981+
"shape": "Short"
982+
},
983+
"EnumMember": {
984+
"shape": "EnumType"
985+
},
986+
"SimpleList": {
987+
"shape": "ListOfStrings"
988+
},
989+
"ListOfEnums": {
990+
"shape": "ListOfEnums"
991+
},
992+
"ListOfMaps": {
993+
"shape": "ListOfMapStringToString"
994+
},
995+
"ListOfStructs": {
996+
"shape": "ListOfSimpleStructs"
997+
},
998+
"MapOfStringToIntegerList": {
999+
"shape": "MapOfStringToIntegerList"
1000+
},
1001+
"MapOfStringToString": {
1002+
"shape": "MapOfStringToString"
1003+
},
1004+
"MapOfStringToStruct": {
1005+
"shape": "MapOfStringToSimpleStruct"
1006+
},
1007+
"MapOfEnumToEnum": {
1008+
"shape": "MapOfEnumToEnum"
1009+
},
1010+
"TimestampMember": {
1011+
"shape": "Timestamp"
1012+
},
1013+
"StructWithNestedTimestampMember": {
1014+
"shape": "StructWithTimestamp"
1015+
},
1016+
"BlobArg": {
1017+
"shape": "BlobType"
1018+
},
1019+
"StructWithNestedBlob": {
1020+
"shape": "StructWithNestedBlobType"
1021+
},
1022+
"BlobMap": {
1023+
"shape": "BlobMapType"
1024+
},
1025+
"ListOfBlobs": {
1026+
"shape": "ListOfBlobsType"
1027+
},
1028+
"RecursiveStruct": {
1029+
"shape": "RecursiveStructType"
1030+
},
1031+
"PolymorphicTypeWithSubTypes": {
1032+
"shape": "BaseType"
1033+
},
1034+
"PolymorphicTypeWithoutSubTypes": {
1035+
"shape": "SubTypeOne"
1036+
},
1037+
"SetPrefixedMember": {
1038+
"shape": "String"
1039+
},
1040+
"UnionMember": {
1041+
"shape": "AllTypesUnionStructure"
1042+
}
1043+
}
9561044
}
9571045
}
9581046
}

0 commit comments

Comments
 (0)