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

Clarify defaulting behavior of response code binding #1111

Merged
Merged
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
3 changes: 2 additions & 1 deletion docs/source/1.0/spec/core/http-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,8 @@ Conflicts with

Marking an output ``structure`` member with this trait can be used to provide
different response codes for an operation, like a 200 or 201 for a PUT
operation.
operation. If this member isn't provided, server implementations MUST default
to the `code` set by the :ref:`http-trait`.

.. rubric:: ``httpResponseCode`` is only used on output

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ apply HttpResponseCode @httpResponseTests([
Status: 201,
}
},
{
id: "RestJsonHttpResponseCodeDefaultsToModeledCode",
documentation: """
Binds the http response code to the http trait's code if the
code isn't explicitly set. A client would be parsing the
http response code, so this would always be present, but
a server doesn't require it to be set to serialize a request.""",
protocol: restJson1,
code: 200,
headers: {
"Content-Type": "application/json",
},
body: "{}",
bodyMediaType: "application/json",
// A client would parse the http response code, and so for clients it
// will always be present, but a server doesn't require it to be set.
params: {},
appliesTo: "server"
},
{
id: "RestJsonHttpResponseCodeWithNoPayload",
documentation: """
Expand Down