|
36 | 36 | import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
|
37 | 37 | import software.amazon.smithy.typescript.codegen.integration.HttpProtocolGeneratorUtils;
|
38 | 38 | import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator.GenerationContext;
|
39 |
| -import software.amazon.smithy.utils.IoUtils; |
40 | 39 | import software.amazon.smithy.utils.SmithyInternalApi;
|
41 | 40 |
|
42 | 41 | /**
|
@@ -120,21 +119,20 @@ static void generateJsonParseBody(GenerationContext context) {
|
120 | 119 | static void generateXmlParseBody(GenerationContext context) {
|
121 | 120 | TypeScriptWriter writer = context.getWriter();
|
122 | 121 |
|
123 |
| - // Include function that decodes XML escape characters. |
124 |
| - writer.write(IoUtils.readUtf8Resource(AwsProtocolUtils.class, "decodeEscapedXML.ts")); |
125 |
| - |
126 | 122 | // Include an XML body parser used to deserialize documents from HTTP responses.
|
127 | 123 | writer.addImport("SerdeContext", "__SerdeContext", "@aws-sdk/types");
|
128 | 124 | writer.addImport("getValueFromTextNode", "__getValueFromTextNode", "@aws-sdk/smithy-client");
|
129 | 125 | writer.addDependency(AwsDependency.XML_PARSER);
|
| 126 | + writer.addDependency(AwsDependency.HTML_ENTITIES); |
| 127 | + writer.addDependency(AwsDependency.TYPES_HTML_ENTITIES); |
130 | 128 | writer.addImport("parse", "xmlParse", "fast-xml-parser");
|
| 129 | + writer.addImport("decode", "heDecode", "he"); |
131 | 130 | writer.openBlock("const parseBody = (streamBody: any, context: __SerdeContext): "
|
132 | 131 | + "any => collectBodyString(streamBody, context).then(encoded => {", "});", () -> {
|
133 | 132 | writer.openBlock("if (encoded.length) {", "}", () -> {
|
134 | 133 | writer.write("const parsedObj = xmlParse(encoded, { attributeNamePrefix: '', "
|
135 | 134 | + "ignoreAttributes: false, parseNodeValue: false, trimValues: false, "
|
136 |
| - + "tagValueProcessor: (val, tagName) => val.trim() === '' ? " |
137 |
| - + "'': decodeEscapedXML(val) });"); |
| 135 | + + "tagValueProcessor: (val, tagName) => val.trim() === '' ? '': heDecode(val) });"); |
138 | 136 | writer.write("const textNodeName = '#text';");
|
139 | 137 | writer.write("const key = Object.keys(parsedObj)[0];");
|
140 | 138 | writer.write("const parsedObjToReturn = parsedObj[key];");
|
|
0 commit comments