Skip to content

Commit

Permalink
Update @httpResponseCode to not be applicable to @input structures
Browse files Browse the repository at this point in the history
- Changed the selector of `@httpResponseCode` to not select structures
  with the `@input` trait applied
- Updated the docs for `@httpResponseCode`
- Move `http-trait-conflicts` test to a `.smithy` file

Resolves #1105
  • Loading branch information
Steven Yuan committed Aug 26, 2022
1 parent b0f2bc2 commit e0cd375
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 41 deletions.
17 changes: 9 additions & 8 deletions docs/source-1.0/spec/core/http-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <http-protocol-document-payloads>` 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 <http-protocol-document-payloads>`
sent in the body of the request.


.. smithy-trait:: smithy.api#cors
Expand Down
17 changes: 9 additions & 8 deletions docs/source-2.0/spec/http-bindings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <http-protocol-document-payloads>` 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 <http-protocol-document-payloads>`
sent in the body of the request.


.. smithy-trait:: smithy.api#cors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$version: "2.0"

namespace ns.foo

@input
structure HttpOperationInput {

@httpResponseCode
Int: Integer

}
Original file line number Diff line number Diff line change
@@ -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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$version: "2.0"

namespace ns.foo

@output
structure HttpOperationOutput {

@required
@httpResponseCode
@httpLabel
@httpQuery("foo")
@httpHeader("x-amz-foo")
Int: Integer

}

0 comments on commit e0cd375

Please sign in to comment.