Skip to content

Commit

Permalink
allow override of union deserializer (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Oct 17, 2023
1 parent 0cbd15a commit 9c303eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .changeset/green-files-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@ private HttpBinding readPayload(
+ "= __expectObject(await parseBody(output.body, context));");
} else if (target instanceof UnionShape) {
// If payload is a Union, then we need to parse the string into JavaScript object.
writer.addImport("expectUnion", "__expectUnion", TypeScriptDependency.AWS_SMITHY_CLIENT);
importUnionDeserializer(writer);
writer.write("const data: Record<string, any> | undefined "
+ "= __expectUnion(await parseBody(output.body, context));");
} else if (target instanceof StringShape || target instanceof DocumentShape) {
Expand All @@ -2422,6 +2422,10 @@ private HttpBinding readPayload(
return binding;
}

protected void importUnionDeserializer(TypeScriptWriter writer) {
writer.addImport("expectUnion", "__expectUnion", TypeScriptDependency.AWS_SMITHY_CLIENT);
}

/**
* Writes the code needed to deserialize the input payload of a request.
*
Expand Down

0 comments on commit 9c303eb

Please sign in to comment.