From ec9d8cf2242e71ff1837c1d78bc640da4698c25c Mon Sep 17 00:00:00 2001 From: JordonPhillips Date: Mon, 28 Feb 2022 15:08:13 +0100 Subject: [PATCH] Clarify defaulting behavior of response code binding --- docs/source/1.0/spec/core/http-traits.rst | 3 ++- .../model/restJson1/http-response-code.smithy | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/source/1.0/spec/core/http-traits.rst b/docs/source/1.0/spec/core/http-traits.rst index 966656798e3..ec64fc9a24d 100644 --- a/docs/source/1.0/spec/core/http-traits.rst +++ b/docs/source/1.0/spec/core/http-traits.rst @@ -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 diff --git a/smithy-aws-protocol-tests/model/restJson1/http-response-code.smithy b/smithy-aws-protocol-tests/model/restJson1/http-response-code.smithy index bc69b9031a9..c167ea5f0d1 100644 --- a/smithy-aws-protocol-tests/model/restJson1/http-response-code.smithy +++ b/smithy-aws-protocol-tests/model/restJson1/http-response-code.smithy @@ -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: """