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

Add compliance test for sparse query parameters #172

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
36 changes: 35 additions & 1 deletion modules/protocol-tests/resources/META-INF/smithy/Pizza.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -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="
]

}
])
1 change: 1 addition & 0 deletions modules/protocol-tests/resources/META-INF/smithy/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Pizza.smithy
RoundTrip.smithy
Version.smithy
HttpPayloadWithDefault.smithy
SparseQueryParameter.smithy
test-config.json