Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "feature",
"description": "Added protocol test to test xml attribute members that are declared between non-attribute members.",
"pull_requests": [
"[#2870](https://github.com/smithy-lang/smithy/pull/2870)"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,87 @@ apply XmlAttributesOnPayload @httpResponseTests([
structure XmlAttributesPayloadRequest with [XmlAttributesInputOutput] {}

structure XmlAttributesPayloadResponse with [XmlAttributesInputOutput] {}

/// This example serializes an XML attribute on a payload when it's defined in the middle of the member list.
/// This tests that implementations correctly write attributes immediately after the element start tag,
/// which is critical for languages like C# where attribute writing must happen before child elements.
@idempotent
@http(uri: "/XmlAttributesInMiddle", method: "PUT")
operation XmlAttributesInMiddle {
input := {
@httpPayload
payload: XmlAttributesInMiddlePayloadRequest
}
output := {
@httpPayload
payload: XmlAttributesInMiddlePayloadResponse
}
}

apply XmlAttributesInMiddle @httpRequestTests([
{
id: "XmlAttributesInMiddle",
documentation: "Serializes XML attributes on a payload when the xmlAttribute trait targets a member in the middle of the member list",
protocol: restXml,
method: "PUT",
uri: "/XmlAttributesInMiddle",
body: """
<XmlAttributesInMiddlePayloadRequest test="attributeValue">
<foo>Foo</foo>
<baz>Baz</baz>
</XmlAttributesInMiddlePayloadRequest>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "application/xml"
},
params: {
payload: {
foo: "Foo",
attr: "attributeValue",
baz: "Baz"
}
}
}
])

apply XmlAttributesInMiddle @httpResponseTests([
{
id: "XmlAttributesInMiddle",
documentation: "Deserializes XML attributes on a payload when the xmlAttribute trait targets a member in the middle of the member list",
protocol: restXml,
code: 200,
body: """
<XmlAttributesInMiddlePayloadResponse test="attributeValue">
<foo>Foo</foo>
<baz>Baz</baz>
</XmlAttributesInMiddlePayloadResponse>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "application/xml"
},
params: {
payload: {
foo: "Foo",
attr: "attributeValue",
baz: "Baz"
}
}
}
])

@mixin
structure XmlAttributesMiddleMemberInputOutput {
foo: String,

@xmlAttribute
@xmlName("test")
attr: String,

baz: String,
}

structure XmlAttributesInMiddlePayloadRequest with [XmlAttributesMiddleMemberInputOutput] {}

structure XmlAttributesInMiddlePayloadResponse with [XmlAttributesMiddleMemberInputOutput] {}
1 change: 1 addition & 0 deletions smithy-aws-protocol-tests/model/restXml/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ service RestXml {
// @xmlAttribute tests
XmlAttributes,
XmlAttributesOnPayload,
XmlAttributesInMiddle,

// @xmlNamespace trait tests
XmlNamespaces,
Expand Down
Loading