Skip to content

Commit

Permalink
Add protocol tests for 0/false query params
Browse files Browse the repository at this point in the history
  • Loading branch information
milesziemer committed Dec 13, 2023
1 parent 33441f0 commit afd247d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
31 changes: 31 additions & 0 deletions codegen-client-test/model/rest-xml-extras.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ service RestXmlExtras {
StringHeader,
CreateFoo,
RequiredMember,
// TODO(https://github.com/smithy-lang/smithy-rs/issues/3315)
ZeroAndFalseQueryParams,
]
}

Expand Down Expand Up @@ -254,3 +256,32 @@ structure RequiredMemberInputOutput {
@required
requiredString: String
}

@httpRequestTests([
{
id: "RestXmlZeroAndFalseQueryParamsAreSerialized"
protocol: restXml
code: 200
method: "GET"
uri: "/ZeroAndFalseQueryParams"
body: ""
queryParams: [
"Zero=0",
"False=false"
]
params: {
zeroValue: 0
falseValue: false
}
}
])
@http(uri: "/ZeroAndFalseQueryParams", method: "GET")
operation ZeroAndFalseQueryParams {
input := {
@httpQuery("Zero")
zeroValue: Integer

@httpQuery("False")
falseValue: Boolean
}
}
32 changes: 32 additions & 0 deletions codegen-core/common-test-models/rest-json-extras.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ service RestJsonExtras {
// TODO(https://github.com/smithy-lang/smithy-rs/issues/2968): Remove the following once these tests are included in Smithy
// They're being added in https://github.com/smithy-lang/smithy/pull/1908
HttpPayloadWithUnion,
// TODO(https://github.com/smithy-lang/smithy-rs/issues/3315)
ZeroAndFalseQueryParams,
],
errors: [ExtraError]
}
Expand Down Expand Up @@ -351,3 +353,33 @@ structure EmptyStructWithContentOnWireOpOutput {
operation EmptyStructWithContentOnWireOp {
output: EmptyStructWithContentOnWireOpOutput,
}
@http(uri: "/zero-and-false-query-params", method: "GET")
@httpRequestTests([
{
id: "RestJsonZeroAndFalseQueryParamsAreSerialized",
protocol: restJson1,
code: 200,
method: "GET",
uri: "/zero-and-false-query-params",
body: "",
queryParams: [
"Zero=0",
"False=false"
],
params: {
zeroValue: 0,
falseValue: false
}
}
])
operation ZeroAndFalseQueryParams {
input: ZeroAndFalseQueryParamsInput
}

structure ZeroAndFalseQueryParamsInput {
@httpQuery("Zero")
zeroValue: Integer

@httpQuery("False")
falseValue: Boolean
}

0 comments on commit afd247d

Please sign in to comment.