diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/ResourceOperationInputOutputValidator.java b/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/ResourceOperationInputOutputValidator.java index bfc38cad436..cd194f39d6f 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/ResourceOperationInputOutputValidator.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/ResourceOperationInputOutputValidator.java @@ -33,6 +33,9 @@ import software.amazon.smithy.model.shapes.ResourceShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.traits.NotPropertyTrait; +import software.amazon.smithy.model.traits.PropertyTrait; +import software.amazon.smithy.model.traits.ResourceIdentifierTrait; import software.amazon.smithy.model.validation.AbstractValidator; import software.amazon.smithy.model.validation.ValidationEvent; @@ -214,8 +217,10 @@ private void validateMember( resource.getId(), propertyName))); } } else if (!identifierMembers.contains(member.getMemberName())) { - events.add(error(member, String.format("Member `%s` does not target a property or identifier" - + " for resource `%s`", member.getMemberName(), resource.getId().toString()))); + events.add(error(member, String.format("Member `%s` does not target a property or identifier for resource " + + "`%s`. If it is an identifier, apply the `%s` trait. If it is a property, apply the `%s` trait. " + + "If it is neither, apply the `%s` trait.", member.getMemberName(), resource.getId().toString(), + ResourceIdentifierTrait.ID, PropertyTrait.ID, NotPropertyTrait.ID))); } } } diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-properties/invalid-output-identifier.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-properties/invalid-output-identifier.errors index dfc8e9c5f3d..fa8be2b281e 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-properties/invalid-output-identifier.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-properties/invalid-output-identifier.errors @@ -1 +1 @@ -[ERROR] com.example#CreateResourceOutput$id: Member `id` does not target a property or identifier for resource `com.example#Resource1` | ResourceOperationInputOutput +[ERROR] com.example#CreateResourceOutput$id: Member `id` does not target a property or identifier for resource `com.example#Resource1`. If it is an identifier, apply the `smithy.api#resourceIdentifier` trait. If it is a property, apply the `smithy.api#property` trait. If it is neither, apply the `smithy.api#notProperty` trait. | ResourceOperationInputOutput