Skip to content

Commit b1fd177

Browse files
Add rest xml protocol tests for nested maps
Resolves #748
1 parent e3cd1c1 commit b1fd177

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

smithy-aws-protocol-tests/model/restXml/document-maps.smithy

+150
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,153 @@ map FlattenedXmlMapWithXmlNamespaceOutputMap {
489489
@xmlNamespace(uri: "https://the-value.example.com")
490490
value: String,
491491
}
492+
493+
@http(uri: "/NestedXmlMaps", method: "POST")
494+
operation NestedXmlMaps {
495+
input: NestedXmlMapsInputOutput,
496+
output: NestedXmlMapsInputOutput,
497+
}
498+
499+
structure NestedXmlMapsInputOutput {
500+
nestedMap: NestedMap,
501+
502+
@xmlFlattened
503+
flatNestedMap: NestedMap,
504+
}
505+
506+
map NestedMap {
507+
key: String,
508+
value: FooEnumMap,
509+
}
510+
511+
apply NestedXmlMaps @httpRequestTests([
512+
{
513+
id: "NestedXmlMapRequest",
514+
documentation: "Tests requests with nested maps.",
515+
protocol: restXml,
516+
method: "POST",
517+
uri: "/NestedXmlMaps",
518+
body: """
519+
<NestedXmlMapsInputOutput>
520+
<nestedMap>
521+
<entry>
522+
<key>foo</key>
523+
<value>
524+
<entry>
525+
<key>bar</key>
526+
<value>Bar</value>
527+
</entry>
528+
</value>
529+
</entry>
530+
</nestedMap>
531+
</NestedXmlMapsInputOutput>""",
532+
bodyMediaType: "application/xml",
533+
headers: {
534+
"Content-Type": "application/xml",
535+
},
536+
params: {
537+
nestedMap: {
538+
foo: {
539+
bar: "Bar",
540+
}
541+
}
542+
}
543+
},
544+
{
545+
id: "FlatNestedXmlMapRequest",
546+
documentation: """
547+
Tests requests with nested flat maps. Since maps can only be
548+
flattened when they're structure members, only the outer map is flat.""",
549+
protocol: restXml,
550+
method: "POST",
551+
uri: "/NestedXmlMaps",
552+
body: """
553+
<NestedXmlMapsInputOutput>
554+
<flatNestedMap>
555+
<key>foo</key>
556+
<value>
557+
<entry>
558+
<key>bar</key>
559+
<value>Bar</value>
560+
</entry>
561+
</value>
562+
</flatNestedMap>
563+
</NestedXmlMapsInputOutput>""",
564+
bodyMediaType: "application/xml",
565+
headers: {
566+
"Content-Type": "application/xml",
567+
},
568+
params: {
569+
flatNestedMap: {
570+
foo: {
571+
bar: "Bar",
572+
}
573+
}
574+
}
575+
},
576+
])
577+
578+
apply NestedXmlMaps @httpResponseTests([
579+
{
580+
id: "NestedXmlMapResponse",
581+
documentation: "Tests responses with nested maps.",
582+
protocol: restXml,
583+
code: 200,
584+
body: """
585+
<NestedXmlMapsInputOutput>
586+
<nestedMap>
587+
<entry>
588+
<key>foo</key>
589+
<value>
590+
<entry>
591+
<key>bar</key>
592+
<value>Bar</value>
593+
</entry>
594+
</value>
595+
</entry>
596+
</nestedMap>
597+
</NestedXmlMapsInputOutput>""",
598+
bodyMediaType: "application/xml",
599+
headers: {
600+
"Content-Type": "application/xml",
601+
},
602+
params: {
603+
nestedMap: {
604+
foo: {
605+
bar: "Bar",
606+
}
607+
}
608+
}
609+
},
610+
{
611+
id: "FlatNestedXmlMapResponse",
612+
documentation: """
613+
Tests responses with nested flat maps. Since maps can only be
614+
flattened when they're structure members, only the outer map is flat.""",
615+
protocol: restXml,
616+
code: 200,
617+
body: """
618+
<NestedXmlMapsInputOutput>
619+
<flatNestedMap>
620+
<key>foo</key>
621+
<value>
622+
<entry>
623+
<key>bar</key>
624+
<value>Bar</value>
625+
</entry>
626+
</value>
627+
</flatNestedMap>
628+
</NestedXmlMapsInputOutput>""",
629+
bodyMediaType: "application/xml",
630+
headers: {
631+
"Content-Type": "application/xml",
632+
},
633+
params: {
634+
flatNestedMap: {
635+
foo: {
636+
bar: "Bar",
637+
}
638+
}
639+
}
640+
},
641+
])

smithy-aws-protocol-tests/model/restXml/main.smithy

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ service RestXml {
7373
XmlLists,
7474
XmlMaps,
7575
XmlMapsXmlName,
76+
NestedXmlMaps,
7677
FlattenedXmlMap,
7778
FlattenedXmlMapWithXmlName,
7879
FlattenedXmlMapWithXmlNamespace,

0 commit comments

Comments
 (0)