Skip to content

Commit

Permalink
fix(fast-xml-parser): populate contents from '#text' if available (aw…
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored and AllanZhengYP committed Mar 20, 2020
1 parent 18b84eb commit a101bc1
Show file tree
Hide file tree
Showing 23 changed files with 184 additions and 23 deletions.
9 changes: 8 additions & 1 deletion clients/client-auto-scaling/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9544,7 +9544,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-cloudformation/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10730,7 +10730,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-cloudfront/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13650,7 +13650,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-cloudsearch/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5856,7 +5856,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-cloudwatch/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6066,7 +6066,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-docdb/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10102,7 +10102,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-ec2/protocols/Aws_ec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73139,7 +73139,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-elastic-beanstalk/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8918,7 +8918,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9164,7 +9164,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-elastic-load-balancing/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6334,7 +6334,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-elasticache/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12805,7 +12805,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-iam/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21920,7 +21920,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-neptune/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13923,7 +13923,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-rds/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29806,7 +29806,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-redshift/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20549,7 +20549,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-route-53/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10089,7 +10089,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-s3-control/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3465,7 +3465,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-s3/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14965,7 +14965,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-ses/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11913,7 +11913,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-sns/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6245,7 +6245,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-sqs/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3625,7 +3625,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
9 changes: 8 additions & 1 deletion clients/client-sts/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
parseNodeValue: false,
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
});
return parsedObj[Object.keys(parsedObj)[0]];
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return parsedObjToReturn;
}
return {};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,14 @@ static void generateXmlParseBody(GenerationContext context) {
writer.write("const parsedObj = xmlParse(encoded, { attributeNamePrefix: '', "
+ "ignoreAttributes: false, parseNodeValue: false, tagValueProcessor: (val, tagName) "
+ "=> decodeEscapedXML(val) });");
writer.write("return parsedObj[Object.keys(parsedObj)[0]];");
writer.write("const textNodeName = '#text';");
writer.write("const key = Object.keys(parsedObj)[0];");
writer.write("const parsedObjToReturn = parsedObj[key];");
writer.openBlock("if (parsedObjToReturn[textNodeName]) {", "}", () -> {
writer.write("parsedObjToReturn[key] = parsedObjToReturn[textNodeName];");
writer.write("delete parsedObjToReturn[textNodeName];");
});
writer.write("return parsedObjToReturn;");
});
writer.write("return {};");
});
Expand Down

0 comments on commit a101bc1

Please sign in to comment.