Skip to content

Commit

Permalink
Add help text to ResourceOperationInputOutput event
Browse files Browse the repository at this point in the history
  • Loading branch information
kstich committed Dec 19, 2024
1 parent 43486ae commit 50eb16d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)));
}
}
}
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 50eb16d

Please sign in to comment.