Skip to content

Commit 1cdbade

Browse files
committed
fix(codegen): read xmlTrait from inputShape while naming wrapper
1 parent fbd405c commit 1cdbade

File tree

1 file changed

+8
-2
lines changed
  • codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen

1 file changed

+8
-2
lines changed

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import software.amazon.smithy.model.shapes.UnionShape;
3232
import software.amazon.smithy.model.traits.StreamingTrait;
3333
import software.amazon.smithy.model.traits.TimestampFormatTrait.Format;
34+
import software.amazon.smithy.model.traits.XmlNameTrait;
3435
import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
3536
import software.amazon.smithy.typescript.codegen.integration.HttpBindingProtocolGenerator;
3637
import software.amazon.smithy.utils.SmithyInternalApi;
@@ -164,13 +165,18 @@ protected void serializeInputDocument(
164165
writer.write("body = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\";");
165166

166167
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);
168175

169176
// Add @xmlNamespace value of the service to the root node,
170177
// fall back to one from the input shape.
171178
boolean serviceXmlns = AwsProtocolUtils.writeXmlNamespace(context, serviceShape, "bodyNode");
172179
if (!serviceXmlns) {
173-
StructureShape inputShape = context.getModel().expectShape(inputShapeId, StructureShape.class);
174180
AwsProtocolUtils.writeXmlNamespace(context, inputShape, "bodyNode");
175181
}
176182

0 commit comments

Comments
 (0)