Skip to content

Commit

Permalink
fix(client-lex-runtime-v2): serialize eventstream payload properly (#…
Browse files Browse the repository at this point in the history
…3655)

* fix(client-lex-runtime-v2): serialize eventstream payload properly

* chore(codegen): simplify the event playload writer interface
  • Loading branch information
AllanZhengYP committed Jun 13, 2022
1 parent 06bf40e commit 757f883
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
18 changes: 12 additions & 6 deletions clients/client-lex-runtime-v2/src/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,8 @@ const serializeAws_restJson1AudioInputEvent_event = (input: AudioInputEvent, con
},
body: new Uint8Array(),
};
message.body = serializeAws_restJson1AudioInputEvent(input, context);
const body = serializeAws_restJson1AudioInputEvent(input, context);
message.body = context.utf8Decoder(JSON.stringify(body));
return message;
};
const serializeAws_restJson1ConfigurationEvent_event = (
Expand All @@ -1054,7 +1055,8 @@ const serializeAws_restJson1ConfigurationEvent_event = (
},
body: new Uint8Array(),
};
message.body = serializeAws_restJson1ConfigurationEvent(input, context);
const body = serializeAws_restJson1ConfigurationEvent(input, context);
message.body = context.utf8Decoder(JSON.stringify(body));
return message;
};
const serializeAws_restJson1DisconnectionEvent_event = (
Expand All @@ -1068,7 +1070,8 @@ const serializeAws_restJson1DisconnectionEvent_event = (
},
body: new Uint8Array(),
};
message.body = serializeAws_restJson1DisconnectionEvent(input, context);
const body = serializeAws_restJson1DisconnectionEvent(input, context);
message.body = context.utf8Decoder(JSON.stringify(body));
return message;
};
const serializeAws_restJson1DTMFInputEvent_event = (input: DTMFInputEvent, context: __SerdeContext): __Message => {
Expand All @@ -1079,7 +1082,8 @@ const serializeAws_restJson1DTMFInputEvent_event = (input: DTMFInputEvent, conte
},
body: new Uint8Array(),
};
message.body = serializeAws_restJson1DTMFInputEvent(input, context);
const body = serializeAws_restJson1DTMFInputEvent(input, context);
message.body = context.utf8Decoder(JSON.stringify(body));
return message;
};
const serializeAws_restJson1PlaybackCompletionEvent_event = (
Expand All @@ -1093,7 +1097,8 @@ const serializeAws_restJson1PlaybackCompletionEvent_event = (
},
body: new Uint8Array(),
};
message.body = serializeAws_restJson1PlaybackCompletionEvent(input, context);
const body = serializeAws_restJson1PlaybackCompletionEvent(input, context);
message.body = context.utf8Decoder(JSON.stringify(body));
return message;
};
const serializeAws_restJson1TextInputEvent_event = (input: TextInputEvent, context: __SerdeContext): __Message => {
Expand All @@ -1104,7 +1109,8 @@ const serializeAws_restJson1TextInputEvent_event = (input: TextInputEvent, conte
},
body: new Uint8Array(),
};
message.body = serializeAws_restJson1TextInputEvent(input, context);
const body = serializeAws_restJson1TextInputEvent(input, context);
message.body = context.utf8Decoder(JSON.stringify(body));
return message;
};
const deserializeAws_restJson1AccessDeniedException_event = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ protected void serializeInputDocumentBody(
serializeDocumentBody(context, documentBindings);
}

@Override
protected void serializeInputEventDocumentPayload(GenerationContext context) {
TypeScriptWriter writer = context.getWriter();
writer.write("message.body = context.utf8Decoder(body.toString());");
}

@Override
protected void serializeOutputDocumentBody(
GenerationContext context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ protected void serializeInputPayload(
serializePayload(context, payloadBinding);
}

@Override
protected void serializeInputEventDocumentPayload(GenerationContext context) {
TypeScriptWriter writer = context.getWriter();
writer.write("message.body = context.utf8Decoder(JSON.stringify(body));");
}

@Override
protected void serializeOutputPayload(
GenerationContext context,
Expand Down

0 comments on commit 757f883

Please sign in to comment.