diff --git a/docs/source-1.0/spec/core/http-traits.rst b/docs/source-1.0/spec/core/http-traits.rst index ebebd477065..49fb3fb7551 100644 --- a/docs/source-1.0/spec/core/http-traits.rst +++ b/docs/source-1.0/spec/core/http-traits.rst @@ -1137,10 +1137,11 @@ Summary Trait selector .. code-block:: none - structure > member :test(> integer) + structure :not([trait|input]) > member :test(> integer) The ``httpResponseCode`` trait can be applied to ``structure`` members - that target an ``integer``. + that target an ``integer`` within any ``structure`` that has no ``input`` + trait applied. Value type Annotation trait. Conflicts with @@ -1157,12 +1158,12 @@ to the `code` set by the :ref:`http-trait`. .. rubric:: ``httpResponseCode`` is only used on output -``httpResponseCode`` is ignored when resolving the HTTP bindings of an -operation's input structure. This means that if a structure that contains -members marked with the ``httpResponseCode`` trait is used as the top-level -input structure of an operation, then those members are sent as part of the -:ref:`protocol-specific document ` sent in -the body of the request. +``httpResponseCode`` is ignored when resolving the HTTP bindings of any +structure except an operation's output structure. This means that if a +structure that contains members marked with the ``httpResponseCode`` trait +is not used as an output structure of an operation, then those members are +sent as part of the :ref:`protocol-specific document ` +sent in the body of the request. .. smithy-trait:: smithy.api#cors diff --git a/docs/source-2.0/spec/http-bindings.rst b/docs/source-2.0/spec/http-bindings.rst index ee8ae939be6..237c495180f 100644 --- a/docs/source-2.0/spec/http-bindings.rst +++ b/docs/source-2.0/spec/http-bindings.rst @@ -1139,10 +1139,11 @@ Summary Trait selector .. code-block:: none - structure > member :test(> integer) + structure :not([trait|input]) > member :test(> integer) The ``httpResponseCode`` trait can be applied to ``structure`` members - that target an ``integer``. + that target an ``integer`` within any ``structure`` that has no ``input`` + trait applied. Value type Annotation trait. Conflicts with @@ -1159,12 +1160,12 @@ to the `code` set by the :ref:`http-trait`. .. rubric:: ``httpResponseCode`` is only used on output -``httpResponseCode`` is ignored when resolving the HTTP bindings of an -operation's input structure. This means that if a structure that contains -members marked with the ``httpResponseCode`` trait is used as the top-level -input structure of an operation, then those members are sent as part of the -:ref:`protocol-specific document ` sent in -the body of the request. +``httpResponseCode`` is ignored when resolving the HTTP bindings of any +structure except an operation's output structure. This means that if a +structure that contains members marked with the ``httpResponseCode`` trait +is not used as an output structure of an operation, then those members are +sent as part of the :ref:`protocol-specific document ` +sent in the body of the request. .. smithy-trait:: smithy.api#cors diff --git a/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy b/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy index e159f104306..715ec891404 100644 --- a/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy +++ b/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy @@ -855,7 +855,7 @@ integer httpError /// status code. The value MAY differ from the HTTP status code provided /// on the response. @trait( - selector: "structure > member :test(> integer)", + selector: "structure :not([trait|input]) > member :test(> integer)", structurallyExclusive: "member", conflicts: [httpLabel, httpQuery, httpHeader, httpPrefixHeaders, httpPayload, httpQueryParams], breakingChanges: [{change: "any"}] diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-response-code-input-conflicts.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-response-code-input-conflicts.errors new file mode 100644 index 00000000000..e1668858acf --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-response-code-input-conflicts.errors @@ -0,0 +1 @@ +[ERROR] ns.foo#HttpOperationInput$Int: Trait `httpResponseCode` cannot be applied to `ns.foo#HttpOperationInput$Int`. This trait may only be applied to shapes that match the following selector: structure :not([trait|input]) > member :test(> integer) | TraitTarget diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-response-code-input-conflicts.smithy b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-response-code-input-conflicts.smithy new file mode 100644 index 00000000000..3857f0175bd --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-response-code-input-conflicts.smithy @@ -0,0 +1,11 @@ +$version: "2.0" + +namespace ns.foo + +@input +structure HttpOperationInput { + + @httpResponseCode + Int: Integer + +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.errors index 28cf8acde8c..25ef52ec5be 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.errors @@ -1 +1 @@ -[ERROR] ns.foo#HttpOperationInput$Int: Found conflicting traits on member shape: `httpHeader` conflicts with `httpLabel`, `httpHeader` conflicts with `httpQuery`, `httpHeader` conflicts with `httpResponseCode`, `httpLabel` conflicts with `httpHeader`, `httpLabel` conflicts with `httpQuery`, `httpLabel` conflicts with `httpResponseCode`, `httpQuery` conflicts with `httpHeader`, `httpQuery` conflicts with `httpLabel`, `httpQuery` conflicts with `httpResponseCode`, `httpResponseCode` conflicts with `httpHeader`, `httpResponseCode` conflicts with `httpLabel`, `httpResponseCode` conflicts with `httpQuery` | TraitConflict +[ERROR] ns.foo#HttpOperationOutput$Int: Found conflicting traits on member shape: `httpHeader` conflicts with `httpLabel`, `httpHeader` conflicts with `httpQuery`, `httpHeader` conflicts with `httpResponseCode`, `httpLabel` conflicts with `httpHeader`, `httpLabel` conflicts with `httpQuery`, `httpLabel` conflicts with `httpResponseCode`, `httpQuery` conflicts with `httpHeader`, `httpQuery` conflicts with `httpLabel`, `httpQuery` conflicts with `httpResponseCode`, `httpResponseCode` conflicts with `httpHeader`, `httpResponseCode` conflicts with `httpLabel`, `httpResponseCode` conflicts with `httpQuery` | TraitConflict diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.json deleted file mode 100644 index 635cee657c5..00000000000 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "smithy": "2.0", - "shapes": { - "ns.foo#HttpOperationInput": { - "type": "structure", - "members": { - "Int": { - "target": "smithy.api#Integer", - "traits": { - "smithy.api#required": {}, - "smithy.api#httpResponseCode": {}, - "smithy.api#httpLabel": {}, - "smithy.api#httpQuery": "foo", - "smithy.api#httpHeader": "x-amz-foo" - } - } - }, - "traits": { - "smithy.api#input": {} - } - } - } -} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.smithy b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.smithy new file mode 100644 index 00000000000..c636c07d23e --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-trait-conflicts.smithy @@ -0,0 +1,15 @@ +$version: "2.0" + +namespace ns.foo + +@output +structure HttpOperationOutput { + + @required + @httpResponseCode + @httpLabel + @httpQuery("foo") + @httpHeader("x-amz-foo") + Int: Integer + +}