Skip to content

Commit

Permalink
Document changeStringEnumsToEnumShapes transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
srchase committed Apr 19, 2023
1 parent f02f5dd commit 83e0118
Showing 1 changed file with 57 additions and 2 deletions.
59 changes: 57 additions & 2 deletions docs/source-2.0/guides/building-models/build-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,52 @@ Applies the transforms defined in the given projection names.
}
}
.. _changeStringEnumsToEnumShapes:

changeStringEnumsToEnumShapes
-----------------------------

Changes string shapes with enum traits into enum shapes.

.. list-table::
:header-rows: 1
:widths: 10 20 70

* - Property
- Type
- Description
* - synthesizeNames
- ``boolean``
- Whether enums without names should have names synthesized if possible.

This transformer will attempt to convert strings with :ref:`enum traits <enum-trait>`
into enum shapes. To successfully convert to an enum shape, each enum
definitions within the source enum trait must have a `name` property, or the
`synthesizeNames` transform config option must be enabled. By default, `synthesizeNames`
is disabled. Additionally, if an enum definition from the enum trait is marked
as deprecated, the :ref:`deprecated trait <deprecated-trait>` will be applied
to the resulting enum shape member. If the enum definition is tagged as
internal, the enum shape member will have the :ref:`internal trait <internal-trait>`
applied.

.. code-block:: json
{
"version": "1.0",
"projections": {
"exampleProjection": {
"transforms": [
{
"name": "changeStringEnumsToEnumShapes",
"args": {
"synthesizeNames": true
}
}
]
}
}
}
.. _changeTypes:

Expand All @@ -490,6 +536,9 @@ Changes the types of shapes.
* - shapeTypes
- ``Map<ShapeId, String>``
- A map of shape IDs to the type to assign to the shape.
* - synthesizeEnumNames
- ``boolean``
- Whether enums without names should have names synthesized if possible.

Only the following shape type changes are supported:

Expand All @@ -498,6 +547,7 @@ Only the following shape type changes are supported:
* Set to list
* Structure to union
* Union to structure
* String to enum

.. code-block:: json
Expand All @@ -511,8 +561,10 @@ Only the following shape type changes are supported:
"args": {
"shapeTypes": {
"smithy.example#Foo": "string",
"smithy.example#Baz": "union"
}
"smithy.example#Baz": "union",
"smithy.example#Qux": "enum"
},
"synthesizeEnumNames": true
}
}
]
Expand All @@ -521,6 +573,9 @@ Only the following shape type changes are supported:
}
.. seealso:: :ref:`changeStringEnumsToEnumShapes`


.. _excludeShapesBySelector-transform:

excludeShapesBySelector
Expand Down

0 comments on commit 83e0118

Please sign in to comment.