Skip to content

Commit

Permalink
Remove sets from IDL v2
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling authored and Michael Dowling committed Jun 30, 2022
1 parent bd976bb commit 34a70ab
Show file tree
Hide file tree
Showing 58 changed files with 221 additions and 445 deletions.
10 changes: 5 additions & 5 deletions docs/source/1.0/spec/aws/aws-ec2-query-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ that affect serialization:
.. |quoted shape name| replace:: ``ec2Query``
.. |name resolution text| replace:: See :ref:`aws.protocols#ec2QueryName-query-key-naming`
for how to serialize a property using a custom name
.. |query collection text| replace::
Each value provided in the collection is serialized as a separate key with
.. |query list text| replace::
Each value provided in the list is serialized as a separate key with
a "." separator and a "1" indexed incrementing counter appended to the
container's key.
.. |query map text| replace::
Expand Down Expand Up @@ -273,10 +273,10 @@ The ``x-www-form-urlencoded`` serialization is:
&Baz.Temp=example3
Collections
===========
Lists
=====

|query collection text|
|query list text|

For example, given the following:

Expand Down
3 changes: 0 additions & 3 deletions docs/source/1.0/spec/aws/aws-json.rst.template
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ to convert each shape type:
- Any JSON value
* - ``list``
- JSON array
* - ``set``
- JSON array. A set is serialized identically as a ``list`` shape,
but only contains unique values.
* - ``map``
- JSON object
* - ``structure``
Expand Down
8 changes: 3 additions & 5 deletions docs/source/1.0/spec/aws/aws-query-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ that affect serialization:

.. |quoted shape name| replace:: ``awsQuery``
.. |name resolution text| replace:: The :ref:`xmlName-trait` can be used to serialize a property using a custom name
.. |query collection text| replace::
Each value provided in the collection is serialized as a separate key with
.. |query list text| replace::
Each value provided in the list is serialized as a separate key with
a "." separator, the string "member", a "." separator, and a "1" indexed
incrementing counter appended to the container's key.
|name resolution text| instead of "member". The :ref:`xmlFlattened-trait`
Expand Down Expand Up @@ -139,8 +139,6 @@ resolved using the following process:
- Default value
* - ``list`` member
- The string literal "member"
* - ``set`` member
- The string literal "member"
* - ``map`` key
- The string literal "key"
* - ``map`` value
Expand Down Expand Up @@ -201,7 +199,7 @@ The ``application/x-www-form-urlencoded`` serialization is:
Collections
===========

|query collection text|
|query list text|

For example, given the following:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ to the input's key.
* - Smithy type
- Request entity
* - ``list``
- |query collection text|
* - ``set``
- A set is serialized identically to a ``list`` shape, but only contains
unique values.
- |query list text|
* - ``map``
- |query map text|
* - ``structure``
Expand Down
5 changes: 1 addition & 4 deletions docs/source/1.0/spec/aws/aws-xml-serialization.rst.template
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@
used to serialize a property using a custom name. The
:ref:`xmlFlattened-trait` can be used to unwrap the values into a
containing structure or union, with the value XML element using the
structure or union member name. See :ref:`xml-list-and-set-serialization`
structure or union member name. See :ref:`xml-list-serialization`
for more.
* - ``set``
- XML element. A set is serialized identically to a ``list`` shape,
but only contains unique values.
* - ``map``
- XML element. Each key-value pair provided in the map is serialized in
a nested XML element with the name ``entry`` that contains nested
Expand Down
68 changes: 0 additions & 68 deletions docs/source/1.0/spec/core/idl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -866,74 +866,6 @@ Traits can be applied to the list shape and its member:
}


.. _idl-set:

Set shapes
----------

A :ref:`set <set>` set shape is defined using a :token:`smithy:set_statement`.

The following example defines a set of strings:

.. tabs::

.. code-tab:: smithy

namespace smithy.example

set StringSet {
member: String
}

.. code-tab:: json

{
"smithy": "1.0",
"shapes": {
"smithy.example#StringSet": {
"type": "set",
"member": {
"target": "smithy.api#String"
}
}
}
}

Traits can be applied to the set shape and its members:

.. tabs::

.. code-tab:: smithy

namespace smithy.example

@deprecated
set StringSet {
@pattern("\\w+")
member: String
}

.. code-tab:: json

{
"smithy": "1.0",
"shapes": {
"smithy.example#StringSet": {
"type": "set",
"member": {
"target": "smithy.api#String",
"traits": {
"smithy.api#pattern": "\\w+"
}
},
"traits": {
"smithy.api#deprecated": {}
}
}
}
}


.. _idl-map:

Map shapes
Expand Down
26 changes: 5 additions & 21 deletions docs/source/1.0/spec/core/json-ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ example defines a shape for each simple type:
}
-------------------
List and set shapes
-------------------
-----------
List shapes
-----------

:ref:`list` and :ref:`set <set>` shapes have a required ``member`` property
that is an :ref:`AST member <ast-member>`.
:ref:`list` shapes have a required ``member`` property that is an
:ref:`AST member <ast-member>`.

The following example defines a list with a string member:

Expand All @@ -184,22 +184,6 @@ The following example defines a list with a string member:
}
}
The following example defines a set with a string member:

.. code-block:: json
{
"smithy": "1.0",
"shapes": {
"smithy.example#MySet": {
"type": "set",
"member": {
"target": "smithy.api#String"
}
}
}
}
.. _ast-member:

Expand Down
128 changes: 26 additions & 102 deletions docs/source/1.0/spec/core/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,23 @@ Shapes are visualized using the following diagram:
└──────────┘ │ └──────────┘ │ ├────────────┤ │ ├─────────────────────────┤
┌──────────┐ │ ┌──────────┐ │ │member │ │ │version │
│document │──┼──│string │ │ └────────────┘ ├────│operations: [Operation]? │
└──────────┘ │ └──────────┘ │ ┌────────────┐ │ │resources: [Resource]? │
┌──────────┐ │ △ ├────Set │ │ └─────────────────────────┘
│timestamp │──┤ │ ├────────────┤ │ ┌─────────────────────────┐
└──────────┘ │ ┌──────────┐ │ │member │ │ │ Operation │
│ │enum │ │ └────────────┘ │ ├─────────────────────────┤
│ └──────────┘ │ ┌────────────┐ │ │input: Structure │
┌───────────────┐ ├────Map │ ├────│output: Structure │
│ «abstract» │ │ ├────────────┤ │ │errors: [Structure]? │
│ Number │ │ │key │ │ └─────────────────────────┘
└───────────────┘ │ │value │ │ ┌─────────────────────────┐
└──────────┘ │ └──────────┘ │ │ │resources: [Resource]? │
┌──────────┐ │ △ │ ┌────────────┐ │ └─────────────────────────┘
│timestamp │──┤ │ ├────│ Map │ │ ┌─────────────────────────┐
└──────────┘ │ ┌──────────┐ │ ├────────────┤ │ │ Operation │
│ │enum │ │ │key │ │ ├─────────────────────────┤
│ └──────────┘ │ │value │ │ │input: Structure │
┌───────────────┐ │ └────────────┘ ├────│output: Structure │
│ «abstract» │ │ | │errors: [Structure]? │
│ Number │ │ ┌────────────┐ │ └─────────────────────────┘
└───────────────┘ ├────│ Structure │ │ ┌─────────────────────────┐
△ │ └────────────┘ │ │ Resource │
┌──────────┐ │ ┌──────────┐ │ ┌────────────┐ │ ├─────────────────────────┤
│float │──┼──│double │ ────│ Structure │ │ │identifiers? │
└──────────┘ │ └──────────┘ └────────────┘ │ │create: Operation? │
┌──────────┐ │ ┌──────────┐ ┌────────────┐ │ │put: Operation? │
│bigInteger│──┼──│bigDecimal│ └────│ Union │ │read: Operation? │
└──────────┘ │ └──────────┘ └────────────┘ └────│update: Operation? │
│float │──┼──│double │ ────│ Union │ │ │identifiers? │
└──────────┘ │ └──────────┘ └────────────┘ │ │create: Operation? │
┌──────────┐ │ ┌──────────┐ │ │put: Operation? │
│bigInteger│──┼──│bigDecimal│ │ │read: Operation? │
└──────────┘ │ └──────────┘ └────│update: Operation? │
┌──────────┐ │ ┌──────────┐ │delete: Operation? │
│byte │──┼──│short │ │list: : Operation? │
└──────────┘ │ └──────────┘ │operations: [Operation]? │
Expand Down Expand Up @@ -633,8 +633,6 @@ Aggregate types are shapes that can contain more than one value.
- Description
* - :ref:`list`
- Ordered collection of homogeneous values
* - :ref:`set`
- (Deprecated) Ordered collection of unique homogeneous values
* - :ref:`map`
- Map data structure that maps string keys to homogeneous values
* - :ref:`structure`
Expand Down Expand Up @@ -723,79 +721,6 @@ The shape ID of the member of a list is the list shape ID followed by
example is ``smithy.example#MyList$member``.


.. _set:

Set
===

.. danger::

Sets are deprecated. Use a list with the :ref:`uniqueItems-trait` instead.

The :dfn:`set` type represents an ordered collection of unique values. A set
shape requires a single member named ``member``. Sets are implicitly considered
to be marked with the :ref:`uniqueItems-trait`, and as such MUST NOT transitively
contain floats, doubles, or documents.

.. important::

Sets are considered sub-type of lists; any place a list is accepted, a set
is accepted.

Sets are defined in the IDL using a :ref:`set_statement <idl-set>`. The
following example defines a set of strings:

.. tabs::

.. code-tab:: smithy

namespace smithy.example

set StringSet {
member: String
}

.. code-tab:: json

{
"smithy": "1.0",
"shapes": {
"smithy.example#StringSet": {
"type": "set",
"member": {
"target": "smithy.api#String"
}
}
}
}

.. rubric:: Sets MUST NOT contain ``null`` values

The values contained in a set are not permitted to be ``null``. ``null`` set
values do not provide much, if any, utility, and set implementations across
programming languages often do not support ``null`` values.

If a client encounters a ``null`` value when deserializing a set returned
from a service, the client MUST discard the ``null`` value. If a service
receives a ``null`` value for a set from a client, it SHOULD reject the
request.

.. rubric:: Set member shape ID

The shape ID of the member of a set is the set shape ID followed by
``$member``. For example, the shape ID of the set member in the above
example is ``smithy.example#StringSet$member``.

.. rubric:: Use insertion order

Implementations SHOULD use insertion ordered sets to ensure that clients and
servers both agree on element ordering so that error messages about specific
items in a set are actionable by clients. If a client and server don't agree
on ordering, then pointing to where a validation error occurs becomes very
challenging. Programming languages that do not support insertion ordered sets
SHOULD store the values of a set in a list.


.. _map:

Map
Expand Down Expand Up @@ -1267,7 +1192,7 @@ Recursive shape definitions

Smithy allows recursive shape definitions with the following limitations:

1. The member of a list, set, or map cannot directly or transitively target
1. The member of a list or map cannot directly or transitively target
its containing shape unless one or more members in the path from the
container back to itself targets a structure or union shape. This ensures
that shapes that are typically impossible to define in various programming
Expand All @@ -1278,7 +1203,7 @@ Smithy allows recursive shape definitions with the following limitations:
:ref:`required <required-trait>` structure members.
3. To ensure a value can be provided for a union, recursive unions MUST
contain at least one path through its members that is not recursive
or steps through a list, set, map, or optional structure member.
or steps through a list, map, or optional structure member.

The following recursive shape definition is **valid**:

Expand Down Expand Up @@ -1631,13 +1556,12 @@ idiomatic.

.. rubric:: Shape types allowed to conflict in a closure

:ref:`Simple types <simple-types>` and :ref:`lists <list>` or
:ref:`sets <set>` of compatible simple types are allowed to conflict because
a conflict for these type would rarely have an impact on generated artifacts.
These kinds of conflicts are only allowed if both conflicting shapes are the
same type and have the exact same traits. In the case of a list or set, a
conflict is only allowed if the members of the conflicting shapes target
compatible shapes.
:ref:`Simple types <simple-types>` and :ref:`lists <list>` of compatible simple
types are allowed to conflict because a conflict for these type would rarely
have an impact on generated artifacts. These kinds of conflicts are only
allowed if both conflicting shapes are the same type and have the exact same
traits. In the case of a list, a conflict is only allowed if the members
of the conflicting shapes target compatible shapes.

.. rubric:: Disambiguating shapes with ``rename``

Expand Down Expand Up @@ -2716,7 +2640,7 @@ target from traits and how their values are defined in
millisecond precision. If a string is provided, it MUST be a valid
:rfc:`3339` string with no UTC offset and optional fractional
precision (for example, ``1985-04-12T23:20:50.52Z``).
* - list and set
* - list
- array
- Each value in the array MUST be compatible with the targeted member.
* - map
Expand Down Expand Up @@ -3123,9 +3047,9 @@ Is changed to:
Then the change to the ``foo`` member from "a" to "b" is backward
incompatible, as is the removal of the ``baz`` member.

.. rubric:: Referring to list and set members
.. rubric:: Referring to list members

The JSON pointer can path into the members of a list or set using a ``member``
The JSON pointer can path into the members of a list using a ``member``
segment.

In the following example, it is a breaking change to change values of lists
Expand Down
Loading

0 comments on commit 34a70ab

Please sign in to comment.