Skip to content

Commit 4411d14

Browse files
Add clientOptional docs
1 parent e10cc0e commit 4411d14

File tree

7 files changed

+83
-1
lines changed

7 files changed

+83
-1
lines changed

docs/source/1.0/spec/aws/aws-core.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,51 @@ Clients SHOULD use an LRU cache implementation with an initial cache limit of
10951095
Clients SHOULD scope the cache globally or to a specific client instance.
10961096

10971097

1098+
.. smithy-trait:: aws.protocols#clientOptional
1099+
1100+
.. _client-optional-trait:
1101+
1102+
--------------------------------------
1103+
``aws.protocols#clientOptional`` trait
1104+
--------------------------------------
1105+
1106+
Summary
1107+
Indicates that a structure member SHOULD be unconditionally generated as
1108+
optional, regardless of other traits.
1109+
Trait selector
1110+
``structure > member``
1111+
1112+
A member of a structure.
1113+
Value type
1114+
Annotation trait.
1115+
1116+
When a member is marked with this trait, it SHOULD always be generated as
1117+
optional even if the member also has the :ref:`required-trait` or
1118+
:ref:`default-trait`. This allows documentation generators to indicate that a
1119+
member is required, even if it is not reflected in the generated code. For
1120+
example:
1121+
1122+
.. code-block:: smithy
1123+
1124+
$version: "2.0"
1125+
namespace smithy.example
1126+
1127+
use aws.api#clientOptional
1128+
1129+
structure ProductData {
1130+
@clientOptional
1131+
@required
1132+
description: String
1133+
}
1134+
1135+
When generating an AWS SDK client for this shape, the
1136+
``ProductData$description`` member SHOULD be generated as an optional member
1137+
rather than required.
1138+
1139+
.. seealso::
1140+
1141+
:ref:`optionality`
1142+
10981143
.. smithy-trait:: aws.protocols#httpChecksum
10991144
.. _aws.protocols#httpChecksum-trait:
11001145

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#. To avoid information disclosure, serializers SHOULD omit the default zero
2+
value of structure members marked with the :ref:`default-trait`.
3+
#. Deserializers MUST tolerate receiving the default zero value of a structure
4+
member marked with the :ref:`default-trait`.
5+
#. Client deserializers MUST fill in a default zero value for structure members
6+
marked with the :ref:`required-trait` that have no serialized value, and the
7+
targeted shape supports zero values. This prevents older clients from
8+
failing to deserialize structures at runtime when the :ref:`required-trait`
9+
is replaced with the :ref:`default-trait`.

docs/source/1.0/spec/aws/aws-json.rst.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ The |quoted shape name| protocol uses the following headers:
5959
service ``ns.example#MyService`` is ``MyService.MyOp``.
6060

6161

62+
---------------------------
63+
Default value serialization
64+
---------------------------
65+
66+
.. include:: aws-default-zero-value.rst.template
67+
68+
6269
-------------------
6370
Shape serialization
6471
-------------------

docs/source/1.0/spec/aws/aws-query-serialization.rst.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
---------------------------
2+
Default value serialization
3+
---------------------------
4+
5+
.. include:: aws-default-zero-value.rst.template
6+
7+
18
---------------------
29
Request serialization
310
---------------------

docs/source/1.0/spec/aws/aws-restjson1-protocol.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ with the ``httpPayload`` trait:
224224
- ``application/json``
225225

226226

227+
---------------------------
228+
Default value serialization
229+
---------------------------
230+
231+
.. include:: aws-default-zero-value.rst.template
232+
233+
227234
------------------------
228235
JSON shape serialization
229236
------------------------

docs/source/1.0/spec/aws/aws-restxml-protocol.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ with the ``httpPayload`` trait:
233233
- ``application/xml``
234234

235235

236+
---------------------------
237+
Default value serialization
238+
---------------------------
239+
240+
.. include:: aws-default-zero-value.rst.template
241+
242+
236243
-----------------------
237244
XML shape serialization
238245
-----------------------

docs/source/1.0/spec/core/model.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ by ``$``, followed by the member name. For example, the shape ID of the ``foo``
786786
member in the above example is ``smithy.example#MyStructure$foo``.
787787

788788

789-
.. optionality:
789+
.. _optionality:
790790

791791
Structure member optionality
792792
----------------------------

0 commit comments

Comments
 (0)