Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for inline io and mixins #1057

Merged
merged 5 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add mixin documentation
  • Loading branch information
JordonPhillips committed Jan 18, 2022
commit 9da850dc119ef81fb16d45ed402845f3a34eeb60
2 changes: 1 addition & 1 deletion designs/mixins.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ The members and traits applied to members of a mixin are copied onto the target
shape. It is sometimes necessary to provide a more specific trait value for a
copied member or to add traits only to a specific copy of a member. Traits can
be added on to these members like any other member. Additionally, Traits can be
applied to these members in the JSON AST using the `apply` type and in the
applied to these members in the JSON AST using the `apply` type and in the
Smithy IDL using `apply` statements.

> Note: Traits applied to shapes supersede any traits inherited from mixins.
Expand Down
47 changes: 38 additions & 9 deletions docs/source/1.0/spec/core/idl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ The Smithy IDL is defined by the following ABNF:
:/ `service_statement`
:/ `operation_statement`
:/ `resource_statement`
simple_shape_statement :`simple_type_name` `ws` `identifier`
mixins :`sp` "with" `ws` "[" 1*(`ws` `shape_id`) `ws` "]"
simple_shape_statement :`simple_type_name` `ws` `identifier` [`mixins`]
simple_type_name :"blob" / "boolean" / "document" / "string"
:/ "byte" / "short" / "integer" / "long"
:/ "float" / "double" / "bigInteger"
Expand All @@ -191,14 +192,14 @@ The Smithy IDL is defined by the following ABNF:
inlineable_property :`node_object_kvp` / `inline_structure`
inline_structure :`node_object_key` `ws` ":=" `ws` `inline_structure_value`
inline_structure_value :`trait_statements` [`mixins` ws] shape_members
list_statement :"list" `ws` `identifier` `ws` `shape_members`
set_statement :"set" `ws` `identifier` `ws` `shape_members`
map_statement :"map" `ws` `identifier` `ws` `shape_members`
structure_statement :"structure" `ws` `identifier` `ws` `shape_members`
union_statement :"union" `ws` `identifier` `ws` `shape_members`
service_statement :"service" `ws` `identifier` `ws` `node_object`
operation_statement :"operation" `ws` `identifier` `ws` `inlineable_properties`
resource_statement :"resource" `ws` `identifier` `ws` `node_object`
list_statement :"list" `ws` `identifier` [`mixins`] `ws` `shape_members`
set_statement :"set" `ws` `identifier` [`mixins`] `ws` `shape_members`
map_statement :"map" `ws` `identifier` [`mixins`] `ws` `shape_members`
structure_statement :"structure" `ws` `identifier` [`mixins`] `ws` `shape_members`
union_statement :"union" `ws` `identifier` [`mixins`] `ws` `shape_members`
service_statement :"service" `ws` `identifier` [`mixins`] `ws` `node_object`
operation_statement :"operation" `ws` `identifier` [`mixins`] `ws` `inlineable_properties`
resource_statement :"resource" `ws` `identifier` [`mixins`] `ws` `node_object`

.. rubric:: Traits

Expand Down Expand Up @@ -1298,6 +1299,34 @@ and defines a :ref:`read <read-lifecycle>` operation:
}


.. _idl-mixins:

Mixins
------

:ref:`Mixins <mixins>` can be added to a shape using the optional
:token:`smithy:mixins` statement as part of the shape type's statement.
JordonPhillips marked this conversation as resolved.
Show resolved Hide resolved
For example:

.. code-block:: smithy

@mixin
structure BaseUser {
userId: String
}

structure UserDetails with [BaseUser] {
username: String
}

@mixin
@sensitive
string SensitiveString

@pattern("[a-zA-Z\.]*")
string SensitiveText with SensitiveString
JordonPhillips marked this conversation as resolved.
Show resolved Hide resolved


.. _documentation-comment:

Documentation comment
Expand Down
44 changes: 44 additions & 0 deletions docs/source/1.0/spec/core/json-ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,50 @@ The following example defines an operation, its input, output, and errors:
}


.. ast-mixins:

------
Mixins
------

All shapes in the ``shapes`` map can contain a ``mixins`` property that
defines the :ref:`mixins` that are added to the shape. ``mixins`` is an
array of :ref:`shape references <ast-shape-reference>` that target shapes
with the :ref:`mixin trait <mixin-trait>`.
JordonPhillips marked this conversation as resolved.
Show resolved Hide resolved

.. code-block:: json

{
"smithy": "2.0",
"shapes": {
"smithy.example#BaseUser": {
"type": "structure",
"members": {
"userId": {
"target": "smithy.api#String"
}
},
"traits": {
"smithy.api#mixin": {}
}
},
"smithy.example#UserDetails": {
"type": "structure",
"members": {
"username": {
"target": "smithy.api#String"
}
},
"mixins": [
{
"target": "smithy.example#BaseUser"
}
]
}
}
}


.. _ast-apply:

--------------
Expand Down
Loading