diff --git a/modules/protocol-tests/resources/META-INF/smithy/Pizza.smithy b/modules/protocol-tests/resources/META-INF/smithy/Pizza.smithy index 1a5124f..1aca4b9 100644 --- a/modules/protocol-tests/resources/META-INF/smithy/Pizza.smithy +++ b/modules/protocol-tests/resources/META-INF/smithy/Pizza.smithy @@ -9,7 +9,7 @@ use alloy#simpleRestJson service PizzaAdminService { version: "1.0.0", errors: [GenericServerError, GenericClientError], - operations: [AddMenuItem, GetMenu, Version, Health, HeaderEndpoint, RoundTrip, GetEnum, GetIntEnum, CustomCode, HttpPayloadWithDefault] + operations: [AddMenuItem, GetMenu, Version, Health, HeaderEndpoint, RoundTrip, GetEnum, GetIntEnum, CustomCode, HttpPayloadWithDefault, SparseQueryParam] } @http(method: "POST", uri: "/restaurant/{restaurant}/menu/item", code: 201) @@ -316,3 +316,37 @@ structure HttpPayloadWithDefaultInputOutput { @default("default value") body: String, } + + +@readonly +@http(uri: "/sparseQueryParam", method: "GET") +operation SparseQueryParam { + input: SparseQueryParamInput, + output: SparseQueryParamOutput +} + +structure SparseQueryParamInput { + @httpQuery("foo") + @required + foo: FooList + + @httpQuery("bar") + @required + bar: BarList +} + +structure SparseQueryParamOutput { + @httpPayload + @required + foo: FooList +} + +@sparse +list FooList { + member: String +} + +@sparse +list BarList { + member: Integer +} diff --git a/modules/protocol-tests/resources/META-INF/smithy/SparseQueryParameter.smithy b/modules/protocol-tests/resources/META-INF/smithy/SparseQueryParameter.smithy new file mode 100644 index 0000000..9f50ada --- /dev/null +++ b/modules/protocol-tests/resources/META-INF/smithy/SparseQueryParameter.smithy @@ -0,0 +1,32 @@ +$version: "2.0" + +namespace alloy.test + +use alloy#simpleRestJson +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests + +apply SparseQueryParam @httpRequestTests([ + { + id: "SparseQueryParam" + documentation: "Tests sparse query param serialization" + protocol: simpleRestJson + method: "GET" + uri: "/sparseQueryParam" + params: { + foo: ["bar", null, "baz", ""], + bar: [1, null, 2, null] + } + queryParams: [ + "foo=bar", + "foo", + "foo=baz", + "foo=", + "bar=1", + "bar", + "bar=2", + "bar=" + ] + + } +]) diff --git a/modules/protocol-tests/resources/META-INF/smithy/manifest b/modules/protocol-tests/resources/META-INF/smithy/manifest index 66b4cb5..ba64dba 100644 --- a/modules/protocol-tests/resources/META-INF/smithy/manifest +++ b/modules/protocol-tests/resources/META-INF/smithy/manifest @@ -9,4 +9,5 @@ Pizza.smithy RoundTrip.smithy Version.smithy HttpPayloadWithDefault.smithy +SparseQueryParameter.smithy test-config.json