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

Smithy 1.26.2 upgrade / ensure that even empty lists are serialized #1972

Merged
merged 4 commits into from
Nov 10, 2022
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
5 changes: 5 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ references = ["smithy-rs#1935"]
meta = { "breaking" = true, "tada" = false, "bug" = false }
author = "jdisanti"

[[smithy-rs]]
message = "Upgrade to Smithy 1.26.2"
references = ["smithy-rs#1972"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "rcoh"
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,6 @@ class ServerProtocolTestGenerator(
private val ExpectFail: Set<FailingTest> = setOf(
// Pending merge from the Smithy team: see https://github.com/awslabs/smithy/pull/1477.
FailingTest(RestJson, "RestJsonWithPayloadExpectsImpliedContentType", TestType.MalformedRequest),
FailingTest(RestJson, "RestJsonBodyMalformedMapNullKey", TestType.MalformedRequest),

// Pending resolution from the Smithy team, see https://github.com/awslabs/smithy/issues/1068.
FailingTest(RestJson, "RestJsonHttpWithHeadersButNoPayload", TestType.Request),
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ kotlin.code.style=official

# codegen
smithyGradlePluginVersion=0.6.0
smithyVersion=1.26.0
smithyVersion=1.26.2

# kotlin
kotlinVersion=1.6.21
Expand Down
18 changes: 17 additions & 1 deletion rust-runtime/aws-smithy-query/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl<'a> QueryWriter<'a> {
}
}

#[must_use]
pub struct QueryMapWriter<'a> {
output: &'a mut String,
prefix: Cow<'a, str>,
Expand Down Expand Up @@ -89,6 +90,7 @@ impl<'a> QueryMapWriter<'a> {
}
}

#[must_use]
pub struct QueryListWriter<'a> {
output: &'a mut String,
prefix: Cow<'a, str>,
Expand Down Expand Up @@ -132,10 +134,15 @@ impl<'a> QueryListWriter<'a> {
}

pub fn finish(self) {
// Calling this drops self
// https://github.com/awslabs/smithy/commit/715b1d94ab14764ad43496b016b0c2e85bcf1d1f
// If the list was empty, just serialize the parameter name
if self.next_index == 1 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not required since this is covered by protocol test, but it would be nice to have a Rust unit test for this.

QueryValueWriter::new(self.output, self.prefix).write_param_name();
}
}
}

#[must_use]
pub struct QueryValueWriter<'a> {
output: &'a mut String,
prefix: Cow<'a, str>,
Expand Down Expand Up @@ -229,6 +236,15 @@ mod tests {
assert_eq!("Action=SomeAction&Version=1.0", out);
}

#[test]
fn query_list_writer_empty_list() {
let mut out = String::new();
let mut writer = QueryWriter::new(&mut out, "SomeAction", "1.0");
writer.prefix("myList").start_list(false, None).finish();
writer.finish();
assert_eq!("Action=SomeAction&Version=1.0&myList=", out);
}

#[test]
fn maps() {
let mut out = String::new();
Expand Down