Skip to content

chore: assert deserialized types are correct #2515

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 6 commits into from
Jul 1, 2021

Conversation

JordonPhillips
Copy link
Member

Issue

n/a

Description

This adds expectations for the default member deserialization so that an error will be thrown if the type being deserialized isn't correct.

Testing

Tests were added.

Additional context

See smithy-lang/smithy-typescript#365 for the other half of this


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

@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@623f80f). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2515   +/-   ##
=======================================
  Coverage        ?   59.64%           
=======================================
  Files           ?      495           
  Lines           ?    26361           
  Branches        ?     6210           
=======================================
  Hits            ?    15724           
  Misses          ?    10637           
  Partials        ?        0           

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 623f80f...c0882c2. Read the comment docs.

@@ -1165,7 +1168,7 @@ export const deserializeAws_restJson1CreateAccessPreviewCommand = async (
};
const data: any = await parseBody(output.body, context);
if (data.id !== undefined && data.id !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't know how the generator is structured, but we should be able to remove this wrapping if function that appears a lot as well. (Though I wouldn't block on it)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is probably due to differences with handling of top-level members.

This adds a few methods to assert that a type is the expected type
before returning it. This is useful to make sure that we aren't
blindly returning json that is invalid.
@trivikr trivikr merged commit dc57732 into aws:main Jul 1, 2021
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2021
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.

4 participants