Skip to content

Commit db4d768

Browse files
author
Chase Coalwell
authored
fix: xml map deser (#965)
1 parent 8859c89 commit db4d768

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ protected void deserializeDocument(GenerationContext context, DocumentShape shap
7979
protected void deserializeMap(GenerationContext context, MapShape shape) {
8080
TypeScriptWriter writer = context.getWriter();
8181
Shape target = context.getModel().expectShape(shape.getValue().getTarget());
82+
String keyLocation = shape.getKey().getTrait(XmlNameTrait.class).map(XmlNameTrait::getValue).orElse("key");
83+
String valueLocation = shape.getValue().getTrait(XmlNameTrait.class).map(XmlNameTrait::getValue)
84+
.orElse("value");
8285

8386
// Get the right serialization for each entry in the map. Undefined
8487
// outputs won't have this deserializer invoked.
8588
writer.write("const mapParams: any = {};");
86-
writer.openBlock("Object.keys(output).forEach(key => {", "});", () -> {
89+
writer.openBlock("output.forEach((pair: any) => {", "});", () -> {
8790
// Dispatch to the output value provider for any additional handling.
88-
writer.write("mapParams[key] = $L;", target.accept(getMemberVisitor("output[key]")));
91+
writer.write("mapParams[pair[$S]] = $L;", keyLocation, target.accept(
92+
getMemberVisitor("pair[\"" + valueLocation + "\"]")));
8993
});
9094
writer.write("return mapParams;");
9195
}

0 commit comments

Comments
 (0)