From bc042566e715240deae699383ec6788a45d78cb4 Mon Sep 17 00:00:00 2001 From: Peter Song Date: Mon, 1 Dec 2025 21:12:50 +0000 Subject: [PATCH 1/3] Add xmlAttributesInMiddle protocol test --- .../restXml/document-xml-attributes.smithy | 84 +++++++++++++++++++ .../model/restXml/main.smithy | 1 + 2 files changed, 85 insertions(+) diff --git a/smithy-aws-protocol-tests/model/restXml/document-xml-attributes.smithy b/smithy-aws-protocol-tests/model/restXml/document-xml-attributes.smithy index 1b5177de307..28b322039cd 100644 --- a/smithy-aws-protocol-tests/model/restXml/document-xml-attributes.smithy +++ b/smithy-aws-protocol-tests/model/restXml/document-xml-attributes.smithy @@ -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: """ + + Foo + Baz + + """, + 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: """ + + Foo + Baz + + """, + 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] {} diff --git a/smithy-aws-protocol-tests/model/restXml/main.smithy b/smithy-aws-protocol-tests/model/restXml/main.smithy index 75380f4a8c3..bf2e764a175 100644 --- a/smithy-aws-protocol-tests/model/restXml/main.smithy +++ b/smithy-aws-protocol-tests/model/restXml/main.smithy @@ -93,6 +93,7 @@ service RestXml { // @xmlAttribute tests XmlAttributes, XmlAttributesOnPayload, + XmlAttributesInMiddle, // @xmlNamespace trait tests XmlNamespaces, From 5ee8456e68c9ab69bab2efa692f67f35f0295b9e Mon Sep 17 00:00:00 2001 From: Peter Song Date: Thu, 4 Dec 2025 10:18:18 -0800 Subject: [PATCH 2/3] Add changelog entry --- .../feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/next-release/feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json diff --git a/.changes/next-release/feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json b/.changes/next-release/feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json new file mode 100644 index 00000000000..8ec29d0465f --- /dev/null +++ b/.changes/next-release/feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json @@ -0,0 +1,7 @@ +{ + "type": "feature", + "description": "Add xmlAttributesInMiddle protocol test", + "pull_requests": [ + "[#2870](https://github.com/smithy-lang/smithy/pull/2870)" + ] +} From ffca7286d2bb9d8ba97ff843a9032dca058afade Mon Sep 17 00:00:00 2001 From: Peter Song Date: Fri, 5 Dec 2025 09:40:26 -0800 Subject: [PATCH 3/3] Update .changes/next-release/feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json Co-authored-by: Jordon Phillips --- .../feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/next-release/feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json b/.changes/next-release/feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json index 8ec29d0465f..5772460cdbe 100644 --- a/.changes/next-release/feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json +++ b/.changes/next-release/feature-5dc78e390fc8e0ba147cdd1d2ab8b84f1d6ce22a.json @@ -1,6 +1,6 @@ { "type": "feature", - "description": "Add xmlAttributesInMiddle protocol test", + "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)" ]