Skip to content

Commit 1e43dde

Browse files
kstichSteven Yuan
authored andcommitted
Expand valid targets of httpPayload
This commit updates the httpPayload trait to allow targeting a structure member that targets any type. Documentation is updated to clarify how the values of other types are serialized. AWS protocol support for new types of httpPayload marked member targets is unchanged.
1 parent 9adcac3 commit 1e43dde

File tree

5 files changed

+42
-22
lines changed

5 files changed

+42
-22
lines changed

docs/source-1.0/spec/core/http-traits.rst

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,9 @@ the body of the response.
707707
Summary
708708
Binds a single structure member to the body of an HTTP message.
709709
Trait selector
710-
.. code-block:: none
711-
712-
structure > :test(member > :test(string, blob, structure, union, document, list, set, map))
710+
``structure > member``
713711

714-
The ``httpPayload`` trait can be applied to ``structure`` members that
715-
target a ``string``, ``blob``, ``structure``, ``union``, ``document``,
716-
``set``, ``map``, or ``list``.
712+
*Any structure member*
717713
Value type
718714
Annotation trait.
719715
Conflicts with
@@ -777,10 +773,9 @@ or :ref:`httpPrefixHeaders-trait`.
777773

778774
#. When a string or blob member is referenced, the raw value is serialized
779775
as the body of the message.
780-
#. When a :ref:`structure <structure>`, :ref:`union <union>`, :ref:`list <list>`,
781-
:ref:`set <set>`, :ref:`map <map>`, or document type is targeted,
782-
the shape value is serialized as a :ref:`protocol-specific <protocolDefinition-trait>`
783-
document that is sent as the body of the message.
776+
#. When any other type of member is referenced, the shape value is serialized
777+
as a :ref:`protocol-specific <protocolDefinition-trait>` value that is sent
778+
as the body of the message.
784779

785780

786781
.. smithy-trait:: smithy.api#httpPrefixHeaders

docs/source-2.0/spec/http-bindings.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -709,14 +709,9 @@ the body of the response.
709709
Summary
710710
Binds a single structure member to the body of an HTTP message.
711711
Trait selector
712-
.. code-block:: none
713-
714-
structure > :test(member > :test(string, blob, structure, union, document, list, map))
715-
716-
The ``httpPayload`` trait can be applied to ``structure`` members that
717-
target a ``string``, ``blob``, ``structure``, ``union``, ``document``,
718-
``map``, or ``list``.
712+
``structure > member``
719713

714+
*Any structure member*
720715
Value type
721716
Annotation trait.
722717
Conflicts with
@@ -781,9 +776,8 @@ or :ref:`httpPrefixHeaders-trait`.
781776

782777
#. When a string or blob member is referenced, the raw value is serialized
783778
as the body of the message.
784-
#. When a :ref:`structure <structure>`, :ref:`union <union>`, :ref:`list <list>`,
785-
:ref:`map <map>`, or document type is targeted, the shape value is serialized
786-
as a :ref:`protocol-specific <protocolDefinition-trait>` document that is sent
779+
#. When any other type of member is referenced, the shape value is serialized
780+
as a :ref:`protocol-specific <protocolDefinition-trait>` value that is sent
787781
as the body of the message.
788782

789783

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[ERROR] smithy.example#InvalidBindingOperationInput$listBinding: AWS Protocols only support binding the following shape types to the payload: string, blob, structure, union, and document | ProtocolHttpPayload
22
[ERROR] smithy.example#InvalidBindingOperationOutput$mapBinding: AWS Protocols only support binding the following shape types to the payload: string, blob, structure, union, and document | ProtocolHttpPayload
33
[ERROR] smithy.example#InvalidBindingError$setBinding: AWS Protocols only support binding the following shape types to the payload: string, blob, structure, union, and document | ProtocolHttpPayload
4+
[ERROR] smithy.example#InvalidSimpleBindingOperationInput$booleanBinding: AWS Protocols only support binding the following shape types to the payload: string, blob, structure, union, and document | ProtocolHttpPayload
5+
[ERROR] smithy.example#InvalidSimpleBindingOperationOutput$integerBinding: AWS Protocols only support binding the following shape types to the payload: string, blob, structure, union, and document | ProtocolHttpPayload
6+
[ERROR] smithy.example#InvalidSimpleBindingError$doubleBinding: AWS Protocols only support binding the following shape types to the payload: string, blob, structure, union, and document | ProtocolHttpPayload

smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/errorfiles/protocols/aws-protocols-do-not-support-list-set-map-payloads.smithy

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ use smithy.api#httpPayload
1313
@restJson1
1414
service InvalidExample {
1515
version: "2020-12-29",
16-
operations: [InvalidBindingOperation],
16+
operations: [
17+
InvalidBindingOperation,
18+
InvalidSimpleBindingOperation
19+
],
1720
}
1821

1922
@http(method: "POST", uri: "/invalid-payload")
@@ -41,6 +44,31 @@ structure InvalidBindingError {
4144
setBinding: StringSet
4245
}
4346

47+
@http(method: "POST", uri: "/invalid-simple-payload")
48+
operation InvalidSimpleBindingOperation {
49+
input: InvalidSimpleBindingOperationInput,
50+
output: InvalidSimpleBindingOperationOutput,
51+
errors: [InvalidSimpleBindingError],
52+
}
53+
54+
@input
55+
structure InvalidSimpleBindingOperationInput {
56+
@httpPayload
57+
booleanBinding: Boolean,
58+
}
59+
60+
@output
61+
structure InvalidSimpleBindingOperationOutput {
62+
@httpPayload
63+
integerBinding: Integer,
64+
}
65+
66+
@error("client")
67+
structure InvalidSimpleBindingError {
68+
@httpPayload
69+
doubleBinding: Double
70+
}
71+
4472
list StringList {
4573
member: String
4674
}

smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ string httpPrefixHeaders
832832

833833
/// Binds a single structure member to the body of an HTTP request.
834834
@trait(
835-
selector: "structure > :test(member > :test(string, blob, structure, union, document, list, map))",
835+
selector: "structure > member",
836836
conflicts: [httpLabel, httpQuery, httpHeader, httpPrefixHeaders, httpResponseCode, httpQueryParams],
837837
structurallyExclusive: "member",
838838
breakingChanges: [{change: "presence"}]

0 commit comments

Comments
 (0)