-
Notifications
You must be signed in to change notification settings - Fork 190
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
Allow 'null' variants in unions #3481
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
rustTemplate( | ||
""" | ||
if let #{Some}(#{Ok}(#{Token}::ValueNull { .. })) = tokens.peek() { | ||
#{skip_value}(tokens)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling skip_value
seems excessive if you already know it's null. Should just be able to pop
it after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the approach looks good, only a server test needs to be updated.
e818699
to
2e0e037
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
Once we're inside of a `{}` JSON object, a known union variant must be provided. Servers must not accept `{}` as "the union shape was not set" when the union shape is optional (which was the behavior in smithy-rs prior to smithy-lang/smithy-rs#3481). This commit adds a protocol test to pin this behavior.
Once we're inside of a `{}` JSON object, a known union variant must be provided. Servers must not accept `{}` as "the union shape was not set" when the union shape is optional (which was the behavior in smithy-rs prior to smithy-lang/smithy-rs#3481). This commit adds a protocol test to pin this behavior.
Motivation and Context
Description
Update the JSON parser generator to allow for
null
to be set in unions. Servers can send unions like this:This caused our parser to fail.
Testing
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.