Skip to content

Commit 87af396

Browse files
authored
fix(fast-xml-parser): populate contents from '#text' if available (#993)
1 parent 87a7137 commit 87af396

File tree

23 files changed

+184
-23
lines changed

23 files changed

+184
-23
lines changed

clients/client-auto-scaling/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9544,7 +9544,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
95449544
parseNodeValue: false,
95459545
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
95469546
});
9547-
return parsedObj[Object.keys(parsedObj)[0]];
9547+
const textNodeName = "#text";
9548+
const key = Object.keys(parsedObj)[0];
9549+
const parsedObjToReturn = parsedObj[key];
9550+
if (parsedObjToReturn[textNodeName]) {
9551+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
9552+
delete parsedObjToReturn[textNodeName];
9553+
}
9554+
return parsedObjToReturn;
95489555
}
95499556
return {};
95509557
});

clients/client-cloudformation/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10730,7 +10730,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
1073010730
parseNodeValue: false,
1073110731
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
1073210732
});
10733-
return parsedObj[Object.keys(parsedObj)[0]];
10733+
const textNodeName = "#text";
10734+
const key = Object.keys(parsedObj)[0];
10735+
const parsedObjToReturn = parsedObj[key];
10736+
if (parsedObjToReturn[textNodeName]) {
10737+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
10738+
delete parsedObjToReturn[textNodeName];
10739+
}
10740+
return parsedObjToReturn;
1073410741
}
1073510742
return {};
1073610743
});

clients/client-cloudfront/protocols/Aws_restXml.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13650,7 +13650,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
1365013650
parseNodeValue: false,
1365113651
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
1365213652
});
13653-
return parsedObj[Object.keys(parsedObj)[0]];
13653+
const textNodeName = "#text";
13654+
const key = Object.keys(parsedObj)[0];
13655+
const parsedObjToReturn = parsedObj[key];
13656+
if (parsedObjToReturn[textNodeName]) {
13657+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
13658+
delete parsedObjToReturn[textNodeName];
13659+
}
13660+
return parsedObjToReturn;
1365413661
}
1365513662
return {};
1365613663
});

clients/client-cloudsearch/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5856,7 +5856,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
58565856
parseNodeValue: false,
58575857
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
58585858
});
5859-
return parsedObj[Object.keys(parsedObj)[0]];
5859+
const textNodeName = "#text";
5860+
const key = Object.keys(parsedObj)[0];
5861+
const parsedObjToReturn = parsedObj[key];
5862+
if (parsedObjToReturn[textNodeName]) {
5863+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
5864+
delete parsedObjToReturn[textNodeName];
5865+
}
5866+
return parsedObjToReturn;
58605867
}
58615868
return {};
58625869
});

clients/client-cloudwatch/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6066,7 +6066,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
60666066
parseNodeValue: false,
60676067
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
60686068
});
6069-
return parsedObj[Object.keys(parsedObj)[0]];
6069+
const textNodeName = "#text";
6070+
const key = Object.keys(parsedObj)[0];
6071+
const parsedObjToReturn = parsedObj[key];
6072+
if (parsedObjToReturn[textNodeName]) {
6073+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
6074+
delete parsedObjToReturn[textNodeName];
6075+
}
6076+
return parsedObjToReturn;
60706077
}
60716078
return {};
60726079
});

clients/client-docdb/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10102,7 +10102,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
1010210102
parseNodeValue: false,
1010310103
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
1010410104
});
10105-
return parsedObj[Object.keys(parsedObj)[0]];
10105+
const textNodeName = "#text";
10106+
const key = Object.keys(parsedObj)[0];
10107+
const parsedObjToReturn = parsedObj[key];
10108+
if (parsedObjToReturn[textNodeName]) {
10109+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
10110+
delete parsedObjToReturn[textNodeName];
10111+
}
10112+
return parsedObjToReturn;
1010610113
}
1010710114
return {};
1010810115
});

clients/client-ec2/protocols/Aws_ec2.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73139,7 +73139,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
7313973139
parseNodeValue: false,
7314073140
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
7314173141
});
73142-
return parsedObj[Object.keys(parsedObj)[0]];
73142+
const textNodeName = "#text";
73143+
const key = Object.keys(parsedObj)[0];
73144+
const parsedObjToReturn = parsedObj[key];
73145+
if (parsedObjToReturn[textNodeName]) {
73146+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
73147+
delete parsedObjToReturn[textNodeName];
73148+
}
73149+
return parsedObjToReturn;
7314373150
}
7314473151
return {};
7314573152
});

clients/client-elastic-beanstalk/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8918,7 +8918,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
89188918
parseNodeValue: false,
89198919
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
89208920
});
8921-
return parsedObj[Object.keys(parsedObj)[0]];
8921+
const textNodeName = "#text";
8922+
const key = Object.keys(parsedObj)[0];
8923+
const parsedObjToReturn = parsedObj[key];
8924+
if (parsedObjToReturn[textNodeName]) {
8925+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
8926+
delete parsedObjToReturn[textNodeName];
8927+
}
8928+
return parsedObjToReturn;
89228929
}
89238930
return {};
89248931
});

clients/client-elastic-load-balancing-v2/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9164,7 +9164,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
91649164
parseNodeValue: false,
91659165
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
91669166
});
9167-
return parsedObj[Object.keys(parsedObj)[0]];
9167+
const textNodeName = "#text";
9168+
const key = Object.keys(parsedObj)[0];
9169+
const parsedObjToReturn = parsedObj[key];
9170+
if (parsedObjToReturn[textNodeName]) {
9171+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
9172+
delete parsedObjToReturn[textNodeName];
9173+
}
9174+
return parsedObjToReturn;
91689175
}
91699176
return {};
91709177
});

clients/client-elastic-load-balancing/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6334,7 +6334,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
63346334
parseNodeValue: false,
63356335
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
63366336
});
6337-
return parsedObj[Object.keys(parsedObj)[0]];
6337+
const textNodeName = "#text";
6338+
const key = Object.keys(parsedObj)[0];
6339+
const parsedObjToReturn = parsedObj[key];
6340+
if (parsedObjToReturn[textNodeName]) {
6341+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
6342+
delete parsedObjToReturn[textNodeName];
6343+
}
6344+
return parsedObjToReturn;
63386345
}
63396346
return {};
63406347
});

clients/client-elasticache/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12805,7 +12805,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
1280512805
parseNodeValue: false,
1280612806
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
1280712807
});
12808-
return parsedObj[Object.keys(parsedObj)[0]];
12808+
const textNodeName = "#text";
12809+
const key = Object.keys(parsedObj)[0];
12810+
const parsedObjToReturn = parsedObj[key];
12811+
if (parsedObjToReturn[textNodeName]) {
12812+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
12813+
delete parsedObjToReturn[textNodeName];
12814+
}
12815+
return parsedObjToReturn;
1280912816
}
1281012817
return {};
1281112818
});

clients/client-iam/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21920,7 +21920,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
2192021920
parseNodeValue: false,
2192121921
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
2192221922
});
21923-
return parsedObj[Object.keys(parsedObj)[0]];
21923+
const textNodeName = "#text";
21924+
const key = Object.keys(parsedObj)[0];
21925+
const parsedObjToReturn = parsedObj[key];
21926+
if (parsedObjToReturn[textNodeName]) {
21927+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
21928+
delete parsedObjToReturn[textNodeName];
21929+
}
21930+
return parsedObjToReturn;
2192421931
}
2192521932
return {};
2192621933
});

clients/client-neptune/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13923,7 +13923,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
1392313923
parseNodeValue: false,
1392413924
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
1392513925
});
13926-
return parsedObj[Object.keys(parsedObj)[0]];
13926+
const textNodeName = "#text";
13927+
const key = Object.keys(parsedObj)[0];
13928+
const parsedObjToReturn = parsedObj[key];
13929+
if (parsedObjToReturn[textNodeName]) {
13930+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
13931+
delete parsedObjToReturn[textNodeName];
13932+
}
13933+
return parsedObjToReturn;
1392713934
}
1392813935
return {};
1392913936
});

clients/client-rds/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29806,7 +29806,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
2980629806
parseNodeValue: false,
2980729807
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
2980829808
});
29809-
return parsedObj[Object.keys(parsedObj)[0]];
29809+
const textNodeName = "#text";
29810+
const key = Object.keys(parsedObj)[0];
29811+
const parsedObjToReturn = parsedObj[key];
29812+
if (parsedObjToReturn[textNodeName]) {
29813+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
29814+
delete parsedObjToReturn[textNodeName];
29815+
}
29816+
return parsedObjToReturn;
2981029817
}
2981129818
return {};
2981229819
});

clients/client-redshift/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20549,7 +20549,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
2054920549
parseNodeValue: false,
2055020550
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
2055120551
});
20552-
return parsedObj[Object.keys(parsedObj)[0]];
20552+
const textNodeName = "#text";
20553+
const key = Object.keys(parsedObj)[0];
20554+
const parsedObjToReturn = parsedObj[key];
20555+
if (parsedObjToReturn[textNodeName]) {
20556+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
20557+
delete parsedObjToReturn[textNodeName];
20558+
}
20559+
return parsedObjToReturn;
2055320560
}
2055420561
return {};
2055520562
});

clients/client-route-53/protocols/Aws_restXml.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10089,7 +10089,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
1008910089
parseNodeValue: false,
1009010090
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
1009110091
});
10092-
return parsedObj[Object.keys(parsedObj)[0]];
10092+
const textNodeName = "#text";
10093+
const key = Object.keys(parsedObj)[0];
10094+
const parsedObjToReturn = parsedObj[key];
10095+
if (parsedObjToReturn[textNodeName]) {
10096+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
10097+
delete parsedObjToReturn[textNodeName];
10098+
}
10099+
return parsedObjToReturn;
1009310100
}
1009410101
return {};
1009510102
});

clients/client-s3-control/protocols/Aws_restXml.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3465,7 +3465,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
34653465
parseNodeValue: false,
34663466
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
34673467
});
3468-
return parsedObj[Object.keys(parsedObj)[0]];
3468+
const textNodeName = "#text";
3469+
const key = Object.keys(parsedObj)[0];
3470+
const parsedObjToReturn = parsedObj[key];
3471+
if (parsedObjToReturn[textNodeName]) {
3472+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
3473+
delete parsedObjToReturn[textNodeName];
3474+
}
3475+
return parsedObjToReturn;
34693476
}
34703477
return {};
34713478
});

clients/client-s3/protocols/Aws_restXml.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14965,7 +14965,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
1496514965
parseNodeValue: false,
1496614966
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
1496714967
});
14968-
return parsedObj[Object.keys(parsedObj)[0]];
14968+
const textNodeName = "#text";
14969+
const key = Object.keys(parsedObj)[0];
14970+
const parsedObjToReturn = parsedObj[key];
14971+
if (parsedObjToReturn[textNodeName]) {
14972+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
14973+
delete parsedObjToReturn[textNodeName];
14974+
}
14975+
return parsedObjToReturn;
1496914976
}
1497014977
return {};
1497114978
});

clients/client-ses/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11913,7 +11913,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
1191311913
parseNodeValue: false,
1191411914
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
1191511915
});
11916-
return parsedObj[Object.keys(parsedObj)[0]];
11916+
const textNodeName = "#text";
11917+
const key = Object.keys(parsedObj)[0];
11918+
const parsedObjToReturn = parsedObj[key];
11919+
if (parsedObjToReturn[textNodeName]) {
11920+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
11921+
delete parsedObjToReturn[textNodeName];
11922+
}
11923+
return parsedObjToReturn;
1191711924
}
1191811925
return {};
1191911926
});

clients/client-sns/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6245,7 +6245,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
62456245
parseNodeValue: false,
62466246
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
62476247
});
6248-
return parsedObj[Object.keys(parsedObj)[0]];
6248+
const textNodeName = "#text";
6249+
const key = Object.keys(parsedObj)[0];
6250+
const parsedObjToReturn = parsedObj[key];
6251+
if (parsedObjToReturn[textNodeName]) {
6252+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
6253+
delete parsedObjToReturn[textNodeName];
6254+
}
6255+
return parsedObjToReturn;
62496256
}
62506257
return {};
62516258
});

clients/client-sqs/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3625,7 +3625,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
36253625
parseNodeValue: false,
36263626
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
36273627
});
3628-
return parsedObj[Object.keys(parsedObj)[0]];
3628+
const textNodeName = "#text";
3629+
const key = Object.keys(parsedObj)[0];
3630+
const parsedObjToReturn = parsedObj[key];
3631+
if (parsedObjToReturn[textNodeName]) {
3632+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
3633+
delete parsedObjToReturn[textNodeName];
3634+
}
3635+
return parsedObjToReturn;
36293636
}
36303637
return {};
36313638
});

clients/client-sts/protocols/Aws_query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,14 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => {
17121712
parseNodeValue: false,
17131713
tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
17141714
});
1715-
return parsedObj[Object.keys(parsedObj)[0]];
1715+
const textNodeName = "#text";
1716+
const key = Object.keys(parsedObj)[0];
1717+
const parsedObjToReturn = parsedObj[key];
1718+
if (parsedObjToReturn[textNodeName]) {
1719+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
1720+
delete parsedObjToReturn[textNodeName];
1721+
}
1722+
return parsedObjToReturn;
17161723
}
17171724
return {};
17181725
});

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,14 @@ static void generateXmlParseBody(GenerationContext context) {
126126
writer.write("const parsedObj = xmlParse(encoded, { attributeNamePrefix: '', "
127127
+ "ignoreAttributes: false, parseNodeValue: false, tagValueProcessor: (val, tagName) "
128128
+ "=> decodeEscapedXML(val) });");
129-
writer.write("return parsedObj[Object.keys(parsedObj)[0]];");
129+
writer.write("const textNodeName = '#text';");
130+
writer.write("const key = Object.keys(parsedObj)[0];");
131+
writer.write("const parsedObjToReturn = parsedObj[key];");
132+
writer.openBlock("if (parsedObjToReturn[textNodeName]) {", "}", () -> {
133+
writer.write("parsedObjToReturn[key] = parsedObjToReturn[textNodeName];");
134+
writer.write("delete parsedObjToReturn[textNodeName];");
135+
});
136+
writer.write("return parsedObjToReturn;");
130137
});
131138
writer.write("return {};");
132139
});

0 commit comments

Comments
 (0)