|
31 | 31 | import software.amazon.smithy.model.shapes.UnionShape;
|
32 | 32 | import software.amazon.smithy.model.traits.StreamingTrait;
|
33 | 33 | import software.amazon.smithy.model.traits.TimestampFormatTrait.Format;
|
| 34 | +import software.amazon.smithy.model.traits.XmlNameTrait; |
34 | 35 | import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
|
35 | 36 | import software.amazon.smithy.typescript.codegen.integration.HttpBindingProtocolGenerator;
|
36 | 37 | import software.amazon.smithy.utils.SmithyInternalApi;
|
@@ -164,13 +165,18 @@ protected void serializeInputDocument(
|
164 | 165 | writer.write("body = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\";");
|
165 | 166 |
|
166 | 167 | writer.addImport("XmlNode", "__XmlNode", "@aws-sdk/xml-builder");
|
167 |
| - writer.write("const bodyNode = new __XmlNode($S);", inputShapeId.getName(serviceShape)); |
| 168 | + |
| 169 | + // Handle the @xmlName trait for the input shape. |
| 170 | + StructureShape inputShape = context.getModel().expectShape(inputShapeId, StructureShape.class); |
| 171 | + String nodeName = inputShape.getTrait(XmlNameTrait.class) |
| 172 | + .map(XmlNameTrait::getValue) |
| 173 | + .orElse(inputShapeId.getName(serviceShape)); |
| 174 | + writer.write("const bodyNode = new __XmlNode($S);", nodeName); |
168 | 175 |
|
169 | 176 | // Add @xmlNamespace value of the service to the root node,
|
170 | 177 | // fall back to one from the input shape.
|
171 | 178 | boolean serviceXmlns = AwsProtocolUtils.writeXmlNamespace(context, serviceShape, "bodyNode");
|
172 | 179 | if (!serviceXmlns) {
|
173 |
| - StructureShape inputShape = context.getModel().expectShape(inputShapeId, StructureShape.class); |
174 | 180 | AwsProtocolUtils.writeXmlNamespace(context, inputShape, "bodyNode");
|
175 | 181 | }
|
176 | 182 |
|
|
0 commit comments