From a5a7a50874839c950fc1a2f75f8f4db1276548c8 Mon Sep 17 00:00:00 2001 From: Kevin Stich Date: Fri, 17 Oct 2025 11:23:10 -0700 Subject: [PATCH] Add square bracket encoding protocol tests This commit adds protocol tests to both restJson1 and restXml that validate square brackets ('[' and ']') are not encoded when present in query parameter keys. --- .../model/restJson1/http-query.smithy | 27 +++++++++++++++++++ .../model/restJson1/main.smithy | 1 + .../model/restXml/http-query.smithy | 27 +++++++++++++++++++ .../model/restXml/main.smithy | 1 + 4 files changed, 56 insertions(+) diff --git a/smithy-aws-protocol-tests/model/restJson1/http-query.smithy b/smithy-aws-protocol-tests/model/restJson1/http-query.smithy index 23426e98657..3ac3bb64604 100644 --- a/smithy-aws-protocol-tests/model/restJson1/http-query.smithy +++ b/smithy-aws-protocol-tests/model/restJson1/http-query.smithy @@ -700,3 +700,30 @@ structure QueryParamsAsStringListMapInput { @httpQueryParams foo: StringListMap } + +/// Does not encode `[]` chars in serialized URIs. +@readonly +@http(uri: "/SkipsEncodingSquareBrackets", method: "GET") +operation SkipsEncodingSquareBrackets { + input := { + @httpQuery("brackets[]") + paramWithBrackets: String + } +} + +apply SkipsEncodingSquareBrackets @httpRequestTests([ + { + id: "RestJsonSkipsEncodingSquareBrackets" + documentation: "Do not encode square brackets (`[` and `]`) in the names of query parameters." + protocol: restJson1 + method: "GET" + uri: "/SkipsEncodingSquareBrackets" + body: "" + queryParams: [ + "brackets[]=Text" + ] + params: { + paramWithBrackets: "Text" + } + } +]) diff --git a/smithy-aws-protocol-tests/model/restJson1/main.smithy b/smithy-aws-protocol-tests/model/restJson1/main.smithy index 33321eb69eb..b9a425d6778 100644 --- a/smithy-aws-protocol-tests/model/restJson1/main.smithy +++ b/smithy-aws-protocol-tests/model/restJson1/main.smithy @@ -50,6 +50,7 @@ service RestJson { QueryIdempotencyTokenAutoFill, QueryPrecedence, QueryParamsAsStringListMap, + SkipsEncodingSquareBrackets // @httpPrefixHeaders tests HttpPrefixHeaders, diff --git a/smithy-aws-protocol-tests/model/restXml/http-query.smithy b/smithy-aws-protocol-tests/model/restXml/http-query.smithy index 017003b411e..d0c70d23887 100644 --- a/smithy-aws-protocol-tests/model/restXml/http-query.smithy +++ b/smithy-aws-protocol-tests/model/restXml/http-query.smithy @@ -586,3 +586,30 @@ structure QueryParamsAsStringListMapInput { @httpQueryParams foo: StringListMap } + +/// Does not encode `[]` chars in serialized URIs. +@readonly +@http(uri: "/SkipsEncodingSquareBrackets", method: "GET") +operation SkipsEncodingSquareBrackets { + input := { + @httpQuery("brackets[]") + paramWithBrackets: String + } +} + +apply SkipsEncodingSquareBrackets @httpRequestTests([ + { + id: "RestXmlSkipsEncodingSquareBrackets" + documentation: "Do not encode square brackets (`[` and `]`) in the names of query parameters." + protocol: restXml + method: "GET" + uri: "/SkipsEncodingSquareBrackets" + body: "" + queryParams: [ + "brackets[]=Text" + ] + params: { + paramWithBrackets: "Text" + } + } +]) diff --git a/smithy-aws-protocol-tests/model/restXml/main.smithy b/smithy-aws-protocol-tests/model/restXml/main.smithy index 75380f4a8c3..795f17cc650 100644 --- a/smithy-aws-protocol-tests/model/restXml/main.smithy +++ b/smithy-aws-protocol-tests/model/restXml/main.smithy @@ -45,6 +45,7 @@ service RestXml { QueryIdempotencyTokenAutoFill, QueryPrecedence, QueryParamsAsStringListMap, + SkipsEncodingSquareBrackets // @httpPrefixHeaders tests HttpPrefixHeaders,