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 6 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,33 @@ 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: "{}",
bodyMediaType: "application/json",
82marbag marked this conversation as resolved.
Show resolved Hide resolved
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: "{}",
bodyMediaType: "application/json",
appliesTo: "server"
}
])