-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide suggestions for invalid shape ID targets
When an invalid shape ID target is encountered, a "Did you mean X?" list of shape IDs are suggested if any shape IDs in a model have a Levenshtein edit distance of less than 2 characters. The shape IDs with the lowest distance from the invalid shape ID are suggested. Closes #464. This change also updates the error message for "shape has a/an `X` relationship..." so that is uses the appropriate indefinte articale based on if the relation type starts with a vowel.
- Loading branch information
Showing
5 changed files
with
285 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...es/software/amazon/smithy/model/errorfiles/validators/target-validator-suggestions.errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ERROR] ns.foo#InvalidList1$member: member shape targets an unresolved shape `ns.foo#d`. Did you mean ns.foo#a, ns.foo#b, ns.foo#c? | Target | ||
[ERROR] ns.foo#InvalidList2$member: member shape targets an unresolved shape `ns.foo#dd`. Did you mean ns.foo#a, ns.foo#ab, ns.foo#b, ns.foo#c? | Target | ||
[ERROR] ns.foo#InvalidList3$member: member shape targets an unresolved shape `ns.foo#acb`. Did you mean ns.foo#ab? | Target | ||
[ERROR] ns.foo#Operation: operation shape has an `input` relationship to an unresolved shape `ns.foo#abcd`. Did you mean ns.foo#abc? | Target |
49 changes: 49 additions & 0 deletions
49
...rces/software/amazon/smithy/model/errorfiles/validators/target-validator-suggestions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"smithy": "1.0", | ||
"metadata": { | ||
"suppressions": [ | ||
{"id": "UnreferencedShape", "namespace": "ns.foo"} | ||
] | ||
}, | ||
"shapes": { | ||
"ns.foo#a": { | ||
"type": "string" | ||
}, | ||
"ns.foo#b": { | ||
"type": "string" | ||
}, | ||
"ns.foo#c": { | ||
"type": "string" | ||
}, | ||
"ns.foo#ab": { | ||
"type": "string" | ||
}, | ||
"ns.foo#abc": { | ||
"type": "string" | ||
}, | ||
"ns.foo#InvalidList1": { | ||
"type": "list", | ||
"member": { | ||
"target": "ns.foo#d" | ||
} | ||
}, | ||
"ns.foo#InvalidList2": { | ||
"type": "list", | ||
"member": { | ||
"target": "ns.foo#dd" | ||
} | ||
}, | ||
"ns.foo#InvalidList3": { | ||
"type": "list", | ||
"member": { | ||
"target": "ns.foo#acb" | ||
} | ||
}, | ||
"ns.foo#Operation": { | ||
"type": "operation", | ||
"input": { | ||
"target": "ns.foo#abcd" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters