From 9bf89cefe4d80bdfe05f2240d8e5d3b96393cc70 Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Fri, 15 Nov 2024 11:52:08 -0700 Subject: [PATCH 01/10] Add transform to mark required idempotency tokens client optional --- docs/source-2.0/guides/smithy-build-json.rst | 25 +++++++++++++++ .../MarkIdempotencyTokensClientOptional.java | 27 ++++++++++++++++ ....amazon.smithy.build.ProjectionTransformer | 2 ++ .../core/directed/CodegenDirector.java | 12 +++++++ .../MakeIdempotencyTokenClientOptional.java | 25 +++++++++++++++ .../model/transform/ModelTransformer.java | 14 +++++++++ ...akeIdempotencyTokenClientOptionalTest.java | 31 +++++++++++++++++++ .../model/transform/idempotency-token.smithy | 11 +++++++ 8 files changed, 147 insertions(+) create mode 100644 smithy-build/src/main/java/software/amazon/smithy/build/transforms/MarkIdempotencyTokensClientOptional.java create mode 100644 smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java create mode 100644 smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/transform/idempotency-token.smithy diff --git a/docs/source-2.0/guides/smithy-build-json.rst b/docs/source-2.0/guides/smithy-build-json.rst index cba39798b14..e4adfa2e719 100644 --- a/docs/source-2.0/guides/smithy-build-json.rst +++ b/docs/source-2.0/guides/smithy-build-json.rst @@ -573,6 +573,31 @@ applied. use an :ref:`enum shape ` instead to avoid needing to use this transform. +.. _markIdempotencyTokensClientOptional: + +markIdempotencyTokensClientOptional +----------------------------------- + +Marks required Idempotency token members as ``@clientOptional``. + +Idempotency tokens that are required should fail validation, but shouldn't be required to create a type, +allowing for a default value to get injected when missing. + +.. code-block:: json + + { + "version": "1.0", + "projections": { + "exampleProjection": { + "transforms": [ + { + "name": "markIdempotencyTokensClientOptional" + } + ] + } + } + } + .. _changeTypes: changeTypes diff --git a/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MarkIdempotencyTokensClientOptional.java b/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MarkIdempotencyTokensClientOptional.java new file mode 100644 index 00000000000..59796ffa1c6 --- /dev/null +++ b/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MarkIdempotencyTokensClientOptional.java @@ -0,0 +1,27 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.build.transforms; + +import software.amazon.smithy.build.ProjectionTransformer; +import software.amazon.smithy.build.TransformContext; +import software.amazon.smithy.model.Model; + +/** + * {@code markIdempotencyTokensClientOptional} marks required idempotency token fields clientOptional. + */ +public final class MarkIdempotencyTokensClientOptional implements ProjectionTransformer { + + @Override + public String getName() { + return "markIdempotencyTokensClientOptional"; + } + + @Override + public Model transform(TransformContext context) { + Model model = context.getModel(); + return context.getTransformer().markIdempotencyTokensClientOptional(model); + } +} diff --git a/smithy-build/src/main/resources/META-INF/services/software.amazon.smithy.build.ProjectionTransformer b/smithy-build/src/main/resources/META-INF/services/software.amazon.smithy.build.ProjectionTransformer index 9a251b195da..4d40c2998d1 100644 --- a/smithy-build/src/main/resources/META-INF/services/software.amazon.smithy.build.ProjectionTransformer +++ b/smithy-build/src/main/resources/META-INF/services/software.amazon.smithy.build.ProjectionTransformer @@ -18,6 +18,8 @@ software.amazon.smithy.build.transforms.IncludeShapesByTag software.amazon.smithy.build.transforms.IncludeTags software.amazon.smithy.build.transforms.IncludeTraits software.amazon.smithy.build.transforms.IncludeTraitsByTag +software.amazon.smithy.build.transforms.MarkIdempotencyTokensClientOptional +software.amazon.smithy.build.transforms.RemoveDeprecatedShapes software.amazon.smithy.build.transforms.RemoveTraitDefinitions software.amazon.smithy.build.transforms.RemoveUnusedShapes software.amazon.smithy.build.transforms.RenameShapes diff --git a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java index 13aedaeb8f4..b99e8b9257d 100644 --- a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java +++ b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java @@ -315,6 +315,18 @@ public void removeShapesDeprecatedBeforeVersion(String relativeVersion) { }); } + /** + * Marks idempotency token fields {@code clientOptional}. + * + * @see ModelTransformer#markIdempotencyTokensClientOptional(Model) + */ + public void markIdempotencyTokensClientOptional() { + transforms.add((model, transformer) -> { + LOGGER.finest("Marking Idempotency Token fields `@clientOptional`"); + return transformer.markIdempotencyTokensClientOptional(model); + }); + } + /** * Changes each compatible string shape with the enum trait to an enum shape. * diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java b/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java new file mode 100644 index 00000000000..724242153f0 --- /dev/null +++ b/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java @@ -0,0 +1,25 @@ +package software.amazon.smithy.model.transform; + + +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.Shape; +import software.amazon.smithy.model.traits.ClientOptionalTrait; +import software.amazon.smithy.model.traits.IdempotencyTokenTrait; +import software.amazon.smithy.model.traits.RequiredTrait; + +/** + * Mark Idempotency token members as clientOptional so they can be injected if missing. + */ +final class MarkIdempotencyTokenClientOptional { + public static Model transform(Model model) { + return ModelTransformer.create().mapShapes(model, shape -> { + if (shape.isMemberShape() + && shape.hasTrait(RequiredTrait.class) + && shape.hasTrait(IdempotencyTokenTrait.class) + && !shape.hasTrait(ClientOptionalTrait.class)) { + return Shape.shapeToBuilder(shape).addTrait(new ClientOptionalTrait()).build(); + } + return shape; + }); + } +} diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java index ed2123608d3..0204e4e4008 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java @@ -43,6 +43,7 @@ import software.amazon.smithy.model.traits.synthetic.OriginalShapeIdTrait; import software.amazon.smithy.utils.FunctionalUtils; import software.amazon.smithy.utils.ListUtils; +import sun.awt.ModalityListener; /** * Class used to transform {@link Model}s. @@ -720,4 +721,17 @@ public Model filterDeprecatedRelativeDate(Model model, String relativeDate) { public Model filterDeprecatedRelativeVersion(Model model, String relativeVersion) { return new FilterDeprecatedRelativeVersion(relativeVersion).transform(this, model); } + + /** + * Marks any Idempotency token fields {@code @clientOptional} so that missing tokens can be injected. + * + *

Idempotency tokens that are required should fail validation, but shouldn't be required to create a type, + * allowing for a default value to get injected when missing. + * + * @param model Model to transform. + * @return Returns the transformed model. + */ + public Model markIdempotencyTokensClientOptional(Model model) { + return MarkIdempotencyTokenClientOptional.transform(model); + } } diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java new file mode 100644 index 00000000000..c67c3daa520 --- /dev/null +++ b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java @@ -0,0 +1,31 @@ +package software.amazon.smithy.model.transform; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.Shape; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.traits.ClientOptionalTrait; +import software.amazon.smithy.model.traits.IdempotencyTokenTrait; +import software.amazon.smithy.model.traits.RequiredTrait; + +public class MakeIdempotencyTokenClientOptionalTest { + private static final ShapeId operationInput = ShapeId.from("smithy.example#IdempotencyTokenRequiredInput"); + + @Test + void compareTransform() { + Model before = Model.assembler() + .addImport(FlattenPaginationInfoTest.class.getResource("idempotency-token.smithy")) + .assemble() + .unwrap(); + Model result = ModelTransformer.create().markIdempotencyTokensClientOptional(before); + + Shape input = result.expectShape(operationInput); + Shape member = result.expectShape(input.getMember("token").get().getId()); + + assertTrue(member.hasTrait(ClientOptionalTrait.class)); + assertTrue(member.hasTrait(RequiredTrait.class)); + assertTrue(member.hasTrait(IdempotencyTokenTrait.class)); + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/transform/idempotency-token.smithy b/smithy-model/src/test/resources/software/amazon/smithy/model/transform/idempotency-token.smithy new file mode 100644 index 00000000000..b6975966cdb --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/transform/idempotency-token.smithy @@ -0,0 +1,11 @@ +$version: "2.0" + +namespace smithy.example + +operation IdempotencyTokenRequired { + input := { + @idempotencyToken + @required + token: String + } +} From 38cde40efb3d99b9400d9d7d4b9002e9a30e3299 Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Fri, 15 Nov 2024 12:02:48 -0700 Subject: [PATCH 02/10] Use make instead of mark --- docs/source-2.0/guides/smithy-build-json.rst | 6 +++--- ...onal.java => MakeIdempotencyTokensClientOptional.java} | 8 ++++---- .../software.amazon.smithy.build.ProjectionTransformer | 2 +- .../smithy/codegen/core/directed/CodegenDirector.java | 8 ++++---- .../transform/MakeIdempotencyTokenClientOptional.java | 4 ++-- .../amazon/smithy/model/transform/ModelTransformer.java | 6 +++--- .../transform/MakeIdempotencyTokenClientOptionalTest.java | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) rename smithy-build/src/main/java/software/amazon/smithy/build/transforms/{MarkIdempotencyTokensClientOptional.java => MakeIdempotencyTokensClientOptional.java} (70%) diff --git a/docs/source-2.0/guides/smithy-build-json.rst b/docs/source-2.0/guides/smithy-build-json.rst index e4adfa2e719..053afe3c9ae 100644 --- a/docs/source-2.0/guides/smithy-build-json.rst +++ b/docs/source-2.0/guides/smithy-build-json.rst @@ -575,10 +575,10 @@ applied. .. _markIdempotencyTokensClientOptional: -markIdempotencyTokensClientOptional +makeIdempotencyTokensClientOptional ----------------------------------- -Marks required Idempotency token members as ``@clientOptional``. +Makes required Idempotency token members as ``@clientOptional``. Idempotency tokens that are required should fail validation, but shouldn't be required to create a type, allowing for a default value to get injected when missing. @@ -591,7 +591,7 @@ allowing for a default value to get injected when missing. "exampleProjection": { "transforms": [ { - "name": "markIdempotencyTokensClientOptional" + "name": "makeIdempotencyTokensClientOptional" } ] } diff --git a/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MarkIdempotencyTokensClientOptional.java b/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MakeIdempotencyTokensClientOptional.java similarity index 70% rename from smithy-build/src/main/java/software/amazon/smithy/build/transforms/MarkIdempotencyTokensClientOptional.java rename to smithy-build/src/main/java/software/amazon/smithy/build/transforms/MakeIdempotencyTokensClientOptional.java index 59796ffa1c6..d83b474fd83 100644 --- a/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MarkIdempotencyTokensClientOptional.java +++ b/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MakeIdempotencyTokensClientOptional.java @@ -10,18 +10,18 @@ import software.amazon.smithy.model.Model; /** - * {@code markIdempotencyTokensClientOptional} marks required idempotency token fields clientOptional. + * {@code makeIdempotencyTokensClientOptional} marks required idempotency token fields clientOptional. */ -public final class MarkIdempotencyTokensClientOptional implements ProjectionTransformer { +public final class MakeIdempotencyTokensClientOptional implements ProjectionTransformer { @Override public String getName() { - return "markIdempotencyTokensClientOptional"; + return "makeIdempotencyTokensClientOptional"; } @Override public Model transform(TransformContext context) { Model model = context.getModel(); - return context.getTransformer().markIdempotencyTokensClientOptional(model); + return context.getTransformer().makeIdempotencyTokensClientOptional(model); } } diff --git a/smithy-build/src/main/resources/META-INF/services/software.amazon.smithy.build.ProjectionTransformer b/smithy-build/src/main/resources/META-INF/services/software.amazon.smithy.build.ProjectionTransformer index 4d40c2998d1..560add08326 100644 --- a/smithy-build/src/main/resources/META-INF/services/software.amazon.smithy.build.ProjectionTransformer +++ b/smithy-build/src/main/resources/META-INF/services/software.amazon.smithy.build.ProjectionTransformer @@ -18,7 +18,7 @@ software.amazon.smithy.build.transforms.IncludeShapesByTag software.amazon.smithy.build.transforms.IncludeTags software.amazon.smithy.build.transforms.IncludeTraits software.amazon.smithy.build.transforms.IncludeTraitsByTag -software.amazon.smithy.build.transforms.MarkIdempotencyTokensClientOptional +software.amazon.smithy.build.transforms.MakeIdempotencyTokensClientOptional software.amazon.smithy.build.transforms.RemoveDeprecatedShapes software.amazon.smithy.build.transforms.RemoveTraitDefinitions software.amazon.smithy.build.transforms.RemoveUnusedShapes diff --git a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java index b99e8b9257d..43f181899bf 100644 --- a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java +++ b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java @@ -316,14 +316,14 @@ public void removeShapesDeprecatedBeforeVersion(String relativeVersion) { } /** - * Marks idempotency token fields {@code clientOptional}. + * Makes idempotency token fields {@code clientOptional}. * - * @see ModelTransformer#markIdempotencyTokensClientOptional(Model) + * @see ModelTransformer#makeIdempotencyTokensClientOptional(Model) */ public void markIdempotencyTokensClientOptional() { transforms.add((model, transformer) -> { - LOGGER.finest("Marking Idempotency Token fields `@clientOptional`"); - return transformer.markIdempotencyTokensClientOptional(model); + LOGGER.finest("Making Idempotency Token fields `@clientOptional`"); + return transformer.makeIdempotencyTokensClientOptional(model); }); } diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java b/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java index 724242153f0..97f9195c717 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java @@ -8,9 +8,9 @@ import software.amazon.smithy.model.traits.RequiredTrait; /** - * Mark Idempotency token members as clientOptional so they can be injected if missing. + * Makes Idempotency token members as clientOptional so they can be injected if missing. */ -final class MarkIdempotencyTokenClientOptional { +final class MakeIdempotencyTokenClientOptional { public static Model transform(Model model) { return ModelTransformer.create().mapShapes(model, shape -> { if (shape.isMemberShape() diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java index 0204e4e4008..72153d2dbe2 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java @@ -723,7 +723,7 @@ public Model filterDeprecatedRelativeVersion(Model model, String relativeVersion } /** - * Marks any Idempotency token fields {@code @clientOptional} so that missing tokens can be injected. + * Makes any Idempotency token fields {@code @clientOptional} so that missing tokens can be injected. * *

Idempotency tokens that are required should fail validation, but shouldn't be required to create a type, * allowing for a default value to get injected when missing. @@ -731,7 +731,7 @@ public Model filterDeprecatedRelativeVersion(Model model, String relativeVersion * @param model Model to transform. * @return Returns the transformed model. */ - public Model markIdempotencyTokensClientOptional(Model model) { - return MarkIdempotencyTokenClientOptional.transform(model); + public Model makeIdempotencyTokensClientOptional(Model model) { + return MakeIdempotencyTokenClientOptional.transform(model); } } diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java index c67c3daa520..178b53719dc 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java @@ -19,7 +19,7 @@ void compareTransform() { .addImport(FlattenPaginationInfoTest.class.getResource("idempotency-token.smithy")) .assemble() .unwrap(); - Model result = ModelTransformer.create().markIdempotencyTokensClientOptional(before); + Model result = ModelTransformer.create().makeIdempotencyTokensClientOptional(before); Shape input = result.expectShape(operationInput); Shape member = result.expectShape(input.getMember("token").get().getId()); From 14b22e43c34c944a5eadeaeb9b930875ef4651bc Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Fri, 15 Nov 2024 12:16:50 -0700 Subject: [PATCH 03/10] Make checkstyle happy --- .../transform/MakeIdempotencyTokenClientOptional.java | 10 ++++++++-- .../smithy/model/transform/ModelTransformer.java | 1 - .../MakeIdempotencyTokenClientOptionalTest.java | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java b/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java index 97f9195c717..e1314600830 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java @@ -1,5 +1,9 @@ -package software.amazon.smithy.model.transform; +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +package software.amazon.smithy.model.transform; import software.amazon.smithy.model.Model; import software.amazon.smithy.model.shapes.Shape; @@ -8,9 +12,11 @@ import software.amazon.smithy.model.traits.RequiredTrait; /** - * Makes Idempotency token members as clientOptional so they can be injected if missing. + * Makes Idempotency token members as clientOptional, so they can be injected if missing. */ final class MakeIdempotencyTokenClientOptional { + private MakeIdempotencyTokenClientOptional() {} + public static Model transform(Model model) { return ModelTransformer.create().mapShapes(model, shape -> { if (shape.isMemberShape() diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java index 72153d2dbe2..23e44a74a94 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java @@ -43,7 +43,6 @@ import software.amazon.smithy.model.traits.synthetic.OriginalShapeIdTrait; import software.amazon.smithy.utils.FunctionalUtils; import software.amazon.smithy.utils.ListUtils; -import sun.awt.ModalityListener; /** * Class used to transform {@link Model}s. diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java index 178b53719dc..cf6b3e0ad11 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptionalTest.java @@ -1,3 +1,8 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + package software.amazon.smithy.model.transform; import static org.junit.jupiter.api.Assertions.assertTrue; From 0c3ea820ae34bbf21a957030ed3f50016557935e Mon Sep 17 00:00:00 2001 From: Hunter Mellema <124718352+hpmellema@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:25:29 -0700 Subject: [PATCH 04/10] Update smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java Co-authored-by: Kevin Stich --- .../amazon/smithy/codegen/core/directed/CodegenDirector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java index 43f181899bf..9660234caba 100644 --- a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java +++ b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java @@ -322,7 +322,7 @@ public void removeShapesDeprecatedBeforeVersion(String relativeVersion) { */ public void markIdempotencyTokensClientOptional() { transforms.add((model, transformer) -> { - LOGGER.finest("Making Idempotency Token fields `@clientOptional`"); + LOGGER.finest("Making `@idempotencyToken` fields `@clientOptional`"); return transformer.makeIdempotencyTokensClientOptional(model); }); } From 05b528b14d87d78e48907d8d1701c44a456bf731 Mon Sep 17 00:00:00 2001 From: Hunter Mellema <124718352+hpmellema@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:25:49 -0700 Subject: [PATCH 05/10] Update smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java Co-authored-by: Kevin Stich --- .../amazon/smithy/codegen/core/directed/CodegenDirector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java index 9660234caba..9f828d6cf93 100644 --- a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java +++ b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java @@ -316,7 +316,7 @@ public void removeShapesDeprecatedBeforeVersion(String relativeVersion) { } /** - * Makes idempotency token fields {@code clientOptional}. + * Makes {@code idempotencyToken} fields {@code clientOptional}. * * @see ModelTransformer#makeIdempotencyTokensClientOptional(Model) */ From d685dc43de95a35e7f6aa7c8966be58603f7c31a Mon Sep 17 00:00:00 2001 From: Hunter Mellema <124718352+hpmellema@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:25:59 -0700 Subject: [PATCH 06/10] Update docs/source-2.0/guides/smithy-build-json.rst Co-authored-by: Kevin Stich --- docs/source-2.0/guides/smithy-build-json.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source-2.0/guides/smithy-build-json.rst b/docs/source-2.0/guides/smithy-build-json.rst index 053afe3c9ae..2c8daa9f2bd 100644 --- a/docs/source-2.0/guides/smithy-build-json.rst +++ b/docs/source-2.0/guides/smithy-build-json.rst @@ -580,8 +580,8 @@ makeIdempotencyTokensClientOptional Makes required Idempotency token members as ``@clientOptional``. -Idempotency tokens that are required should fail validation, but shouldn't be required to create a type, -allowing for a default value to get injected when missing. +Idempotency tokens that are required should fail validation, but shouldn't be required to create a type. +This allows a default value to get injected when missing. .. code-block:: json From ead0e909113fd1a208622b029ed97a8e4a0174bc Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Fri, 15 Nov 2024 12:42:21 -0700 Subject: [PATCH 07/10] Address pr feedback --- docs/source-2.0/guides/smithy-build-json.rst | 4 ++-- .../build/transforms/MakeIdempotencyTokensClientOptional.java | 2 +- .../model/transform/MakeIdempotencyTokenClientOptional.java | 2 +- .../amazon/smithy/model/transform/ModelTransformer.java | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source-2.0/guides/smithy-build-json.rst b/docs/source-2.0/guides/smithy-build-json.rst index 2c8daa9f2bd..e5d567c1d38 100644 --- a/docs/source-2.0/guides/smithy-build-json.rst +++ b/docs/source-2.0/guides/smithy-build-json.rst @@ -573,12 +573,12 @@ applied. use an :ref:`enum shape ` instead to avoid needing to use this transform. -.. _markIdempotencyTokensClientOptional: +.. _makeIdempotencyTokensClientOptional: makeIdempotencyTokensClientOptional ----------------------------------- -Makes required Idempotency token members as ``@clientOptional``. +Makes required Idempotency token members :ref:`@clientOptional `. Idempotency tokens that are required should fail validation, but shouldn't be required to create a type. This allows a default value to get injected when missing. diff --git a/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MakeIdempotencyTokensClientOptional.java b/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MakeIdempotencyTokensClientOptional.java index d83b474fd83..afab58be77b 100644 --- a/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MakeIdempotencyTokensClientOptional.java +++ b/smithy-build/src/main/java/software/amazon/smithy/build/transforms/MakeIdempotencyTokensClientOptional.java @@ -10,7 +10,7 @@ import software.amazon.smithy.model.Model; /** - * {@code makeIdempotencyTokensClientOptional} marks required idempotency token fields clientOptional. + * {@code makeIdempotencyTokensClientOptional} makes {@code @idempotencyToken} fields {@code @clientOptional}. */ public final class MakeIdempotencyTokensClientOptional implements ProjectionTransformer { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java b/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java index e1314600830..fb8d01896d6 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/transform/MakeIdempotencyTokenClientOptional.java @@ -12,7 +12,7 @@ import software.amazon.smithy.model.traits.RequiredTrait; /** - * Makes Idempotency token members as clientOptional, so they can be injected if missing. + * Makes {@code idempotencyToken} members {@code clientOptional}, so they can be injected if missing. */ final class MakeIdempotencyTokenClientOptional { private MakeIdempotencyTokenClientOptional() {} diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java index 23e44a74a94..c43d756e594 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java @@ -722,10 +722,10 @@ public Model filterDeprecatedRelativeVersion(Model model, String relativeVersion } /** - * Makes any Idempotency token fields {@code @clientOptional} so that missing tokens can be injected. + * Makes any {@code @idempotencyToken fields {@code @clientOptional} so that missing tokens can be injected. * *

Idempotency tokens that are required should fail validation, but shouldn't be required to create a type, - * allowing for a default value to get injected when missing. + * allowing for a default value to be injected when missing. * * @param model Model to transform. * @return Returns the transformed model. From de96f9c75977b86e9c03a709d8b33132f993167c Mon Sep 17 00:00:00 2001 From: Hunter Mellema <124718352+hpmellema@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:42:49 -0700 Subject: [PATCH 08/10] Update smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java Co-authored-by: Michael Dowling --- .../amazon/smithy/codegen/core/directed/CodegenDirector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java index 9f828d6cf93..b9e9e767bcc 100644 --- a/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java +++ b/smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/directed/CodegenDirector.java @@ -320,7 +320,7 @@ public void removeShapesDeprecatedBeforeVersion(String relativeVersion) { * * @see ModelTransformer#makeIdempotencyTokensClientOptional(Model) */ - public void markIdempotencyTokensClientOptional() { + public void makeIdempotencyTokensClientOptional() { transforms.add((model, transformer) -> { LOGGER.finest("Making `@idempotencyToken` fields `@clientOptional`"); return transformer.makeIdempotencyTokensClientOptional(model); From 7b968c9e6294b43cedc1ffa4c03c07f71c93ec72 Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Fri, 15 Nov 2024 12:51:44 -0700 Subject: [PATCH 09/10] Fix borked javadoc --- .../amazon/smithy/model/transform/ModelTransformer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java index c43d756e594..0c671fd5bc5 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/transform/ModelTransformer.java @@ -722,7 +722,7 @@ public Model filterDeprecatedRelativeVersion(Model model, String relativeVersion } /** - * Makes any {@code @idempotencyToken fields {@code @clientOptional} so that missing tokens can be injected. + * Makes any {@code @idempotencyToken} fields {@code @clientOptional} so that missing tokens can be injected. * *

Idempotency tokens that are required should fail validation, but shouldn't be required to create a type, * allowing for a default value to be injected when missing. From e48663627d6abcb14cc5018f13438b7622ed0479 Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Fri, 15 Nov 2024 12:59:59 -0700 Subject: [PATCH 10/10] Add missing ref --- docs/source-2.0/guides/smithy-build-json.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source-2.0/guides/smithy-build-json.rst b/docs/source-2.0/guides/smithy-build-json.rst index e5d567c1d38..16dbb5c92f5 100644 --- a/docs/source-2.0/guides/smithy-build-json.rst +++ b/docs/source-2.0/guides/smithy-build-json.rst @@ -578,7 +578,7 @@ applied. makeIdempotencyTokensClientOptional ----------------------------------- -Makes required Idempotency token members :ref:`@clientOptional `. +Makes required :ref:`@idempotencyToken ` members :ref:`@clientOptional `. Idempotency tokens that are required should fail validation, but shouldn't be required to create a type. This allows a default value to get injected when missing.