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

Http response code #1241

Merged
merged 7 commits into from
Jun 15, 2022
Merged
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ structure HttpResponseCodeOutput {
Status: Integer
}

@http(method: "GET", uri: "/responseCodeRequired", code: 200)
operation ResponseCodeRequired {
output: ResponseCodeRequiredOutput,
}

@output
structure ResponseCodeRequiredOutput {
@required
@httpResponseCode
responseCode: Integer,
}

@http(method: "GET", uri: "/responseCodeHttpFallback", code: 201)
operation ResponseCodeHttpFallback {
input: ResponseCodeHttpFallbackInputOutput,
output: ResponseCodeHttpFallbackInputOutput,
}

structure ResponseCodeHttpFallbackInputOutput {}

apply HttpResponseCode @httpResponseTests([
{
id: "RestJsonHttpResponseCode",
Expand Down Expand Up @@ -73,3 +93,31 @@ apply HttpResponseCode @httpResponseTests([
appliesTo: "client"
},
])

apply ResponseCodeRequired @httpResponseTests([
{
id: "RestJsonHttpResponseCodeRequired",
documentation: """
This test ensures that servers handle @httpResponseCode being @required.""",
protocol: restJson1,
code: 201,
body: "",
Copy link
Contributor

@gosar gosar Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See similar tests https://github.com/awslabs/smithy/blob/ededf6ba2334f1d006f3c76a257c8812f2f17497/smithy-aws-protocol-tests/model/restJson1/empty-input-output.smithy#L147-L159 and https://github.com/awslabs/smithy/blob/ededf6ba2334f1d006f3c76a257c8812f2f17497/smithy-aws-protocol-tests/model/restJson1/empty-input-output.smithy#L219-L221

server implementations are expected to respond with a JSON object regardless of if the output parameters are empty

You should change these tests to be similar to the above.

I think they way these tests are defined, it would have failed in the TypeScript SSDK - example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gosar, updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they way these tests are defined, it would have failed in the TypeScript SSDK - example

Would it be useful to add some tests from those in this CI?

params: {
responseCode: 201,
},
appliesTo: "server"
}
])

apply ResponseCodeHttpFallback @httpResponseTests([
{
id: "RestJsonHttpResponseCodeNotSetFallsBackToHttpCode",
documentation: """
This test ensures that servers fall back to the code set
by @http if @httpResponseCode is not set.""",
protocol: restJson1,
code: 201,
body: "",
appliesTo: "server"
}
])