Skip to content

feat: populate contents from '#text' recursively in parseBody #1154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 8, 2020

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented May 6, 2020

Issue #, if available:

Description of changes:

  • Populate contents from '#text' recursively in parseBody

  • Verified that:

  • deserializer function:

    • before:
      const deserializeAws_restXmlRenamedListMembers = (
        output: any,
        context: __SerdeContext
      ): string[] => {
        return (output || []).map((entry: any) =>
          entry["#text"] !== undefined ? entry["#text"] : entry
        );
      };
    • after:
      const deserializeAws_restXmlRenamedListMembers = (
        output: any,
        context: __SerdeContext
      ): string[] => {
        return (output || []).map((entry: any) => entry);
      };
  • parseBody:

    • before
      const parseBody = (streamBody: any, context: __SerdeContext): any =>
        collectBodyString(streamBody, context).then(encoded => {
          if (encoded.length) {
            const parsedObj = xmlParse(encoded, {
              attributeNamePrefix: "",
              ignoreAttributes: false,
              parseNodeValue: false,
              tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
            });
            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 {};
        });
    • after
      const parseBody = (streamBody: any, context: __SerdeContext): any =>
        collectBodyString(streamBody, context).then(encoded => {
          if (encoded.length) {
            const parsedObj = xmlParse(encoded, {
              attributeNamePrefix: "",
              ignoreAttributes: false,
              parseNodeValue: false,
              tagValueProcessor: (val, tagName) => decodeEscapedXML(val)
            });
            const textNodeName = "#text";
            const key = Object.keys(parsedObj)[0];
            const parsedObjToReturn = parsedObj[key];
            if (parsedObjToReturn[textNodeName]) {
              parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
              delete parsedObjToReturn[textNodeName];
            }
            return __getValueFromTextNode(parsedObjToReturn);
          }
          return {};
        });

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aws-sdk-js-automation

This comment has been minimized.

@codecov-io
Copy link

Codecov Report

Merging #1154 into master will increase coverage by 0.16%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1154      +/-   ##
==========================================
+ Coverage   73.85%   74.02%   +0.16%     
==========================================
  Files         284      285       +1     
  Lines       13175    12736     -439     
  Branches     3106     2809     -297     
==========================================
- Hits         9731     9428     -303     
+ Misses       3444     3308     -136     
Impacted Files Coverage Δ
...ages/smithy-client/src/get-value-from-text-node.ts 100.00% <ø> (ø)
protocol_tests/aws-ec2/protocols/Aws_ec2.ts 64.37% <ø> (-0.57%) ⬇️
protocol_tests/aws-json/protocols/Aws_json1_1.ts 69.32% <ø> (ø)
protocol_tests/aws-query/protocols/Aws_query.ts 69.48% <ø> (-0.06%) ⬇️
...ol_tests/aws-restjson/protocols/Aws_restJson1_1.ts 65.83% <ø> (ø)
...rotocol_tests/aws-restxml/protocols/Aws_restXml.ts 68.67% <ø> (-0.07%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bcfa99c...61b70fe. Read the comment docs.

@trivikr trivikr force-pushed the remove-hash-text-parsed-obj branch from 61b70fe to c80add7 Compare May 6, 2020 05:57
@trivikr trivikr marked this pull request as ready for review May 6, 2020 05:57
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: c80add7
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@alexforsyth alexforsyth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Great cleanup +1

Copy link
Contributor

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome.

@trivikr trivikr merged commit b3148b4 into aws:master May 8, 2020
@trivikr trivikr deleted the remove-hash-text-parsed-obj branch May 8, 2020 18:05
@lock
Copy link

lock bot commented May 20, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export check for ["#text"] to a utility function
5 participants