Skip to content
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

generate protocol-specific event payload #554

Merged
merged 3 commits into from
Jun 13, 2022

Conversation

AllanZhengYP
Copy link
Contributor

Issue #, if available:
The Lex-runtime-v2 service cannot serialzie the event correctly because the events without eventHeader or eventPayload trait are not serialized, but returned as plain JavaScript object.

For example:

  1. The TextEvent is modeled as structure and serialized into a JavaScript Object(link).
  2. The JavaScript Object was directly passed to the event body(link) without serializing.
  3. This results in the event marshaller fails to the allocate correct bytelength, because it assumes the body to be binary data(link)

Description of changes:
This change expose a new interface serializeInputEventDocumentPayload() which generates the protocol-specific event payload. Specificly as mentioned in the Smithy spec:

A structure and union is serialized as a protocol-specific document.
It should only handle the serialization of structure and union shape into the event payload.

This change refactors the generator caused by the misunderstanding previously.

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

@AllanZhengYP AllanZhengYP requested a review from srchase June 2, 2022 16:10
@AllanZhengYP
Copy link
Contributor Author

Per discussing with @kstich, this PR doesn't handle the case where only a subset of members contains eventHeaders trait and the rest of the members contains implicit eventPayload trait. I need to rework on this PR.

@AllanZhengYP AllanZhengYP marked this pull request as draft June 3, 2022 19:12
@AllanZhengYP
Copy link
Contributor Author

AllanZhengYP commented Jun 5, 2022

Address issue above in commit aws/aws-sdk-js-v3@ad2fa4e. The change excludes serializing the union or structure members with eventHeader trait. It means the protocol-specific serializer will only serialize the members in the event payload.

cc @kstich

@AllanZhengYP AllanZhengYP marked this pull request as ready for review June 5, 2022 05:08
@AllanZhengYP AllanZhengYP force-pushed the serialize-event-payload branch from 1d4e1b2 to 55af99c Compare June 12, 2022 23:40
@AllanZhengYP AllanZhengYP merged commit 3e13fb8 into smithy-lang:main Jun 13, 2022
srchase pushed a commit to srchase/smithy-typescript that referenced this pull request Mar 17, 2023
* expose serializeInputEventDocumentPayload() to generate protocol-specific event payload

* remove the event headers when serializing implicit event payload

* address feedbacks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants