diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/OperationValidator.java b/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/OperationValidator.java index 42e48cd01fa..1b90a842d37 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/OperationValidator.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/OperationValidator.java @@ -95,7 +95,7 @@ private void validateInputOutput( } } else if (relName.equals(invalid)) { // Input shouldn't reference output, and vice versa. - events.add(emitInvalidOperationBinding(rel.getShape(), descriptor, invalid)); + events.add(emitInvalidOperationBinding(rel.getShape(), shape, relName, descriptor)); } else if (rel.getRelationshipType() == RelationshipType.MEMBER_TARGET) { // Members can't target shapes marked with @input or @output. events.add(emitInvalidMemberRef(rel.getShape().asMemberShape().get(), descriptor)); @@ -109,12 +109,19 @@ private void validateInputOutput( } } - private ValidationEvent emitInvalidOperationBinding(Shape operation, String property, String invalid) { + private ValidationEvent emitInvalidOperationBinding( + Shape operation, + Shape target, + String property, + String invalid + ) { return ValidationEvent.builder() .id(OPERATION_INPUT_OUTPUT_MISUSE) .severity(Severity.ERROR) .shape(operation) - .message("Operation " + property + " cannot target structures marked with the @" + invalid + " trait") + .message(String.format( + "Operation `%s` cannot target structures marked with the `@%s` trait: `%s`", + property, invalid, target.getId())) .build(); } diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/operation/input-output-traits/invalid-input-output-operation-bindings.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/operation/input-output-traits/invalid-input-output-operation-bindings.errors index 3f5afdf870f..5e3f02c1e57 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/operation/input-output-traits/invalid-input-output-operation-bindings.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/operation/input-output-traits/invalid-input-output-operation-bindings.errors @@ -1,2 +1,2 @@ -[ERROR] smithy.example#GetFoo: Operation input cannot target structures marked with the @output trait | OperationInputOutputMisuse -[ERROR] smithy.example#GetFoo: Operation output cannot target structures marked with the @input trait | OperationInputOutputMisuse +[ERROR] smithy.example#GetFoo: Operation `input` cannot target structures marked with the `@output` trait: `smithy.example#GetFooOutput` | OperationInputOutputMisuse +[ERROR] smithy.example#GetFoo: Operation `output` cannot target structures marked with the `@input` trait: `smithy.example#GetFooInput` | OperationInputOutputMisuse