// This file defines test cases that serialize lists in XML documents.
$version: "2.0"
namespace aws.protocoltests.restxml
use aws.protocols#restXml
use aws.protocoltests.shared#BooleanList
use aws.protocoltests.shared#EpochSeconds
use aws.protocoltests.shared#FooEnumList
use aws.protocoltests.shared#IntegerEnumList
use aws.protocoltests.shared#GreetingList
use aws.protocoltests.shared#IntegerList
use aws.protocoltests.shared#NestedStringList
use aws.protocoltests.shared#StringList
use aws.protocoltests.shared#StringSet
use aws.protocoltests.shared#TimestampList
use smithy.test#httpRequestTests
use smithy.test#httpResponseTests
/// This test case serializes XML lists for the following cases for both
/// input and output:
///
/// 1. Normal XML lists.
/// 2. Normal XML sets.
/// 3. XML lists of lists.
/// 4. XML lists with @xmlName on its members
/// 5. Flattened XML lists.
/// 6. Flattened XML lists with @xmlName.
/// 7. Flattened XML lists with @xmlNamespace.
/// 8. Lists of structures.
/// 9. Flattened XML list of structures
@idempotent
@http(uri: "/XmlLists", method: "PUT")
operation XmlLists {
input: XmlListsInputOutput,
output: XmlListsInputOutput,
}
apply XmlLists @httpRequestTests([
{
id: "XmlLists",
documentation: "Tests for XML list serialization",
protocol: restXml,
method: "PUT",
uri: "/XmlLists",
body: """
foo
bar
foo
bar
1
2
true
false
2014-04-29T18:30:38Z
2014-04-29T18:30:38Z
Foo
0
1
2
foo
bar
baz
qux
- foo
- bar
hi
bye
yep
nope
-
1
2
-
3
4
5
6
7
8
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "application/xml"
},
params: {
stringList: ["foo", "bar"],
stringSet: ["foo", "bar"],
integerList: [1, 2],
booleanList: [true, false],
timestampList: [1398796238, 1398796238],
enumList: ["Foo", "0"],
intEnumList: [1, 2],
nestedStringList: [["foo", "bar"], ["baz", "qux"]],
renamedListMembers: ["foo", "bar"],
flattenedList: ["hi", "bye"],
flattenedList2: ["yep", "nope"],
structureList: [
{
a: "1",
b: "2",
},
{
a: "3",
b: "4",
}
],
flattenedStructureList: [
{
a: "5",
b: "6",
},
{
a: "7",
b: "8",
}
]
}
}
])
apply XmlLists @httpResponseTests([
{
id: "XmlLists",
documentation: "Tests for XML list serialization",
protocol: restXml,
code: 200,
body: """
foo
bar
foo
bar
1
2
true
false
2014-04-29T18:30:38Z
2014-04-29T18:30:38Z
Foo
0
1
2
foo
bar
baz
qux
- foo
- bar
hi
bye
yep
nope
a
b
a
b
-
1
2
-
3
4
5
6
7
8
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "application/xml"
},
params: {
stringList: ["foo", "bar"],
stringSet: ["foo", "bar"],
integerList: [1, 2],
booleanList: [true, false],
timestampList: [1398796238, 1398796238],
enumList: ["Foo", "0"],
intEnumList: [1, 2],
nestedStringList: [["foo", "bar"], ["baz", "qux"]],
renamedListMembers: ["foo", "bar"],
flattenedList: ["hi", "bye"],
flattenedList2: ["yep", "nope"],
flattenedListWithMemberNamespace: ["a", "b"],
flattenedListWithNamespace: ["a", "b"],
structureList: [
{
a: "1",
b: "2",
},
{
a: "3",
b: "4",
}
],
flattenedStructureList: [
{
a: "5",
b: "6",
},
{
a: "7",
b: "8",
}
]
}
}
])
@idempotent
@http(uri: "/XmlEmptyLists", method: "PUT")
@tags(["client-only"])
operation XmlEmptyLists {
input: XmlListsInputOutput,
output: XmlListsInputOutput,
}
apply XmlEmptyLists @httpRequestTests([
{
id: "XmlEmptyLists",
documentation: "Serializes Empty XML lists",
protocol: restXml,
method: "PUT",
uri: "/XmlEmptyLists",
body: """
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "application/xml"
},
params: {
stringList: [],
stringSet: [],
},
appliesTo: "client",
}
])
apply XmlEmptyLists @httpResponseTests([
{
id: "XmlEmptyLists",
documentation: "Deserializes Empty XML lists",
protocol: restXml,
code: 200,
body: """
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "application/xml"
},
params: {
stringList: [],
stringSet: [],
},
appliesTo: "client",
}
])
structure XmlListsInputOutput {
stringList: StringList,
stringSet: StringSet,
integerList: IntegerList,
booleanList: BooleanList,
timestampList: TimestampList,
enumList: FooEnumList,
intEnumList: IntegerEnumList,
nestedStringList: NestedStringList,
@xmlName("renamed")
renamedListMembers: RenamedListMembers,
@xmlFlattened
// The xmlname on the targeted list is ignored, and the member name is used.
flattenedList: RenamedListMembers,
@xmlName("customName")
@xmlFlattened
// the xmlName trait on the targeted list's member is ignored when
// serializing flattened lists in structures.
flattenedList2: RenamedListMembers,
// The XML namespace of the flattened list's member is used, and
// list's XML namespace is disregarded.
@xmlFlattened
flattenedListWithMemberNamespace: ListWithMemberNamespace,
// Again, the XML namespace of the flattened list is ignored.
// The namespace of the member is used, which is empty, so
// no xmlns attribute appears on the serialized XML.
@xmlFlattened
flattenedListWithNamespace: ListWithNamespace,
@xmlName("myStructureList")
structureList: StructureList,
@xmlFlattened
flattenedStructureList: StructureList
}
list RenamedListMembers {
@xmlName("item")
member: String,
}
list StructureList {
@xmlName("item")
member: StructureListMember,
}
structure StructureListMember {
@xmlName("value")
a: String,
@xmlName("other")
b: String,
}
@xmlNamespace(uri: "https://xml-list.example.com")
list ListWithMemberNamespace {
@xmlNamespace(uri: "https://xml-member.example.com")
member: String,
}
@xmlNamespace(uri: "https://xml-list.example.com")
list ListWithNamespace {
member: String,
}