Unverified Commit 16d212e2 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

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

* Ensure that even empty lists are serialized

* Add must_use annotation & unit test

* Add changelog entry

* Remove test from list of failing tests
parent 4f76e35f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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"
+0 −1
Original line number Diff line number Diff line
@@ -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),
+1 −1
Original line number Diff line number Diff line
@@ -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
+17 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ impl<'a> QueryWriter<'a> {
    }
}

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

#[must_use]
pub struct QueryListWriter<'a> {
    output: &'a mut String,
    prefix: Cow<'a, str>,
@@ -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 {
            QueryValueWriter::new(self.output, self.prefix).write_param_name();
        }
    }
}

#[must_use]
pub struct QueryValueWriter<'a> {
    output: &'a mut String,
    prefix: Cow<'a, str>,
@@ -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();