-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ProtocolTest: Add protocol test for Unions in REST-XML
Adds REST-XML protocol test for union used input and output parameters.
- Loading branch information
Showing
2 changed files
with
279 additions
and
0 deletions.
There are no files selected for viewing
278 changes: 278 additions & 0 deletions
278
smithy-aws-protocol-tests/model/restXml/document-unions.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,278 @@ | ||
// This file defines test cases that serialize synthesized XML documents | ||
// in the payload of HTTP requests and responses. | ||
|
||
$version: "1.0" | ||
|
||
namespace aws.protocoltests.restxml | ||
|
||
use aws.protocols#restXml | ||
use smithy.test#httpRequestTests | ||
use smithy.test#httpResponseTests | ||
|
||
// This example serializes simple scalar types in the top level XML document. | ||
// Note that headers are not serialized in the payload. | ||
@idempotent | ||
@http(uri: "/XmlUnions", method: "PUT") | ||
operation XmlUnions { | ||
input: XmlUnionsInputOutput, | ||
output: XmlUnionsInputOutput | ||
} | ||
|
||
apply XmlUnions @httpRequestTests([ | ||
{ | ||
id: "XmlUnionsWithStructMember", | ||
documentation: "Serializes union struct member", | ||
protocol: restXml, | ||
method: "PUT", | ||
uri: "/XmlUnions", | ||
body: """ | ||
<XmlUnionsInputOutput> | ||
<unionValue> | ||
<structValue> | ||
<stringValue>string</stringValue> | ||
<booleanValue>true</booleanValue> | ||
<byteValue>1</byteValue> | ||
<shortValue>2</shortValue> | ||
<integerValue>3</integerValue> | ||
<longValue>4</longValue> | ||
<floatValue>5.5</floatValue> | ||
<doubleValue>6.5</doubleValue> | ||
</structValue> | ||
</unionValue> | ||
</XmlUnionsInputOutput> | ||
""", | ||
bodyMediaType: "application/xml", | ||
headers: { | ||
"Content-Type": "application/xml", | ||
}, | ||
params: { | ||
unionValue: { | ||
structValue: { | ||
stringValue: "string", | ||
booleanValue: true, | ||
byteValue: 1, | ||
shortValue: 2, | ||
integerValue: 3, | ||
longValue: 4, | ||
floatValue: 5.5, | ||
doubleValue: 6.5, | ||
}, | ||
}, | ||
} | ||
}, | ||
{ | ||
id: "XmlUnionsWithStringMember", | ||
documentation: "serialize union string member", | ||
protocol: restXml, | ||
method: "PUT", | ||
uri: "/XmlUnions", | ||
body: """ | ||
<XmlUnionsInputOutput> | ||
<unionValue> | ||
<stringValue>some string</stringValue> | ||
</unionValue> | ||
</XmlUnionsInputOutput> | ||
""", | ||
bodyMediaType: "application/xml", | ||
headers: { | ||
"Content-Type": "application/xml", | ||
}, | ||
params: { | ||
unionValue: { | ||
stringValue: "some string", | ||
}, | ||
} | ||
}, | ||
{ | ||
id: "XmlUnionsWithBooleanMember", | ||
documentation: "Serializes union boolean member", | ||
protocol: restXml, | ||
method: "PUT", | ||
uri: "/XmlUnions", | ||
body: """ | ||
<XmlUnionsInputOutput> | ||
<unionValue> | ||
<booleanValue>true</booleanValue> | ||
</unionValue> | ||
</XmlUnionsInputOutput> | ||
""", | ||
bodyMediaType: "application/xml", | ||
headers: { | ||
"Content-Type": "application/xml", | ||
}, | ||
params: { | ||
unionValue: { | ||
booleanValue: true, | ||
}, | ||
} | ||
}, | ||
{ | ||
id: "XmlUnionsWithUnionMember", | ||
documentation: "Serializes union union member", | ||
protocol: restXml, | ||
method: "PUT", | ||
uri: "/XmlUnions", | ||
body: """ | ||
<XmlUnionsInputOutput> | ||
<unionValue> | ||
<unionValue> | ||
<booleanValue>true</booleanValue> | ||
</unionValue> | ||
</unionValue> | ||
</XmlUnionsInputOutput> | ||
""", | ||
bodyMediaType: "application/xml", | ||
headers: { | ||
"Content-Type": "application/xml", | ||
}, | ||
params: { | ||
unionValue: { | ||
unionValue: { | ||
booleanValue: true, | ||
}, | ||
}, | ||
} | ||
}, | ||
]) | ||
|
||
apply XmlUnions @httpResponseTests([ | ||
{ | ||
id: "XmlUnionsWithStructMember", | ||
documentation: "Serializes union struct member", | ||
protocol: restXml, | ||
code: 200, | ||
body: """ | ||
<XmlUnionsInputOutput> | ||
<unionValue> | ||
<structValue> | ||
<stringValue>string</stringValue> | ||
<booleanValue>true</booleanValue> | ||
<byteValue>1</byteValue> | ||
<shortValue>2</shortValue> | ||
<integerValue>3</integerValue> | ||
<longValue>4</longValue> | ||
<floatValue>5.5</floatValue> | ||
<doubleValue>6.5</doubleValue> | ||
</structValue> | ||
</unionValue> | ||
</XmlUnionsInputOutput> | ||
""", | ||
bodyMediaType: "application/xml", | ||
headers: { | ||
"Content-Type": "application/xml", | ||
}, | ||
params: { | ||
unionValue: { | ||
structValue: { | ||
stringValue: "string", | ||
booleanValue: true, | ||
byteValue: 1, | ||
shortValue: 2, | ||
integerValue: 3, | ||
longValue: 4, | ||
floatValue: 5.5, | ||
doubleValue: 6.5, | ||
}, | ||
}, | ||
} | ||
}, | ||
{ | ||
id: "XmlUnionsWithStringMember", | ||
documentation: "Serializes union string member", | ||
protocol: restXml, | ||
code: 200, | ||
body: """ | ||
<XmlUnionsInputOutput> | ||
<unionValue> | ||
<stringValue>some string</stringValue> | ||
</unionValue> | ||
</XmlUnionsInputOutput> | ||
""", | ||
bodyMediaType: "application/xml", | ||
headers: { | ||
"Content-Type": "application/xml", | ||
}, | ||
params: { | ||
unionValue: { | ||
stringValue: "some string", | ||
}, | ||
} | ||
}, | ||
{ | ||
id: "XmlUnionsWithBooleanMember", | ||
documentation: "Serializes union boolean member", | ||
protocol: restXml, | ||
code: 200, | ||
body: """ | ||
<XmlUnionsInputOutput> | ||
<unionValue> | ||
<booleanValue>true</booleanValue> | ||
</unionValue> | ||
</XmlUnionsInputOutput> | ||
""", | ||
bodyMediaType: "application/xml", | ||
headers: { | ||
"Content-Type": "application/xml", | ||
}, | ||
params: { | ||
unionValue: { | ||
booleanValue: true, | ||
}, | ||
} | ||
}, | ||
{ | ||
id: "XmlUnionsWithUnionMember", | ||
documentation: "Serializes union union member", | ||
protocol: restXml, | ||
code: 200, | ||
body: """ | ||
<XmlUnionsInputOutput> | ||
<unionValue> | ||
<unionValue> | ||
<booleanValue>true</booleanValue> | ||
</unionValue> | ||
</unionValue> | ||
</XmlUnionsInputOutput> | ||
""", | ||
bodyMediaType: "application/xml", | ||
headers: { | ||
"Content-Type": "application/xml", | ||
}, | ||
params: { | ||
unionValue: { | ||
unionValue: { | ||
booleanValue: true, | ||
}, | ||
}, | ||
} | ||
}, | ||
]) | ||
|
||
structure XmlUnionsInputOutput { | ||
unionValue: XmlUnionShape, | ||
} | ||
|
||
union XmlUnionShape { | ||
stringValue: String, | ||
booleanValue: Boolean, | ||
byteValue: Byte, | ||
shortValue: Short, | ||
integerValue: Integer, | ||
longValue: Long, | ||
floatValue: Float, | ||
doubleValue: Double, | ||
|
||
unionValue: XmlUnionShape, | ||
structValue: XmlNestedUnionStruct, | ||
} | ||
|
||
structure XmlNestedUnionStruct { | ||
stringValue: String, | ||
booleanValue: Boolean, | ||
byteValue: Byte, | ||
shortValue: Short, | ||
integerValue: Integer, | ||
longValue: Long, | ||
floatValue: Float, | ||
doubleValue: Double, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters