Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ private void writeEventBody(
writer.write("body = input.$L;", payloadMemberName);
} else if (payloadShape instanceof StringShape) {
writer.write("body = context.utf8Decoder(input.$L);", payloadMemberName);
} else if (payloadShape instanceof BlobShape || payloadShape instanceof StringShape) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was a copy-paste error from #572

} else if (payloadShape instanceof StructureShape || payloadShape instanceof UnionShape) {
Symbol symbol = getSymbol(context, payloadShape);
String serFunctionName = ProtocolGenerator.getSerFunctionShortName(symbol);
boolean mayElide = serdeElisionIndex.mayElide(payloadShape);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
import software.amazon.smithy.typescript.codegen.knowledge.SerdeElisionIndex;
import software.amazon.smithy.utils.OptionalUtils;
import software.amazon.smithy.utils.SmithyInternalApi;
import software.amazon.smithy.utils.SmithyUnstableApi;

/**
Expand Down Expand Up @@ -107,7 +108,7 @@ public void generateSharedComponents(GenerationContext context) {
getDocumentContentType(),
() -> {
TypeScriptWriter writer = context.getWriter();
writer.write("body = context.utf8Decoder(body);");
serializeEventStreamBodyToBytes(writer);
},
serializingDocumentShapes
);
Expand Down Expand Up @@ -606,6 +607,17 @@ protected String getErrorBodyLocation(GenerationContext context, String outputLo
return outputLocation;
}

/**
* Allows RPC protocols to designate how to convert the body into bytes.
*
* @deprecated superseded by schema-serde.
*/
@Deprecated
@SmithyInternalApi
protected void serializeEventStreamBodyToBytes(TypeScriptWriter writer) {
writer.write("body = context.utf8Decoder(JSON.stringify(body));");
}

/**
* Writes the code needed to deserialize the output document of a response.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ public void generateSharedComponents(GenerationContext context) {
service,
getDocumentContentType(),
() -> {
writer.write("body = context.utf8Decoder(body);");
writer.addImportSubmodule(
"cbor", null,
TypeScriptDependency.SMITHY_CORE, SmithyCoreSubmodules.CBOR
);
writer.write("body = cbor.encode(body);");
},
serializingDocumentShapes
);
Expand Down
Loading