From abcb69910815e0792c8382f7431116210cd8e3f8 Mon Sep 17 00:00:00 2001 From: Michael Dowling Date: Sun, 18 Apr 2021 14:25:49 -0700 Subject: [PATCH] Stop validation on critical loading errors We previously would continue to perform more granular semantic model validation even after an ERROR was encountered while loading the model. If an ERROR is encountered while loading a model, then it is very likely that it can cause a flurry of unrelated validation events to emit errors that would only obscure the root cause of the issue. This commit updates model validation to stop if an ERROR occurred while loading models, if a model has broken shape references, if a shape target targets an invalid shape, or if a resource hierarchy is recursive. This update required various "kitchen-sink" style tests to be updated to account for the new validation behavior. Closes #743 --- .../service-not-configured.json | 2 +- ...ndard-operation-verb-invalid-config.errors | 1 + ...tandard-operation-verb-invalid-config.json | 11 + ...ndard-operation-verb-validator-test.errors | 1 - ...tandard-operation-verb-validator-test.json | 4 - .../smithy/model/loader/LoaderUtils.java | 15 + .../smithy/model/loader/ModelAssembler.java | 4 +- .../smithy/model/loader/ModelValidator.java | 20 ++ .../model/knowledge/PaginatedIndexTest.java | 4 +- ...-trait-must-target-auth-definitions.errors | 2 - .../auth/auth-trait-invalid-shape-id.errors | 1 + .../auth/auth-trait-invalid-shape-id.json | 11 + ...-trait-must-target-auth-definitions.errors | 1 + ...th-trait-must-target-auth-definitions.json | 6 - ...h-trait-must-target-service-schemes.errors | 0 ...uth-trait-must-target-service-schemes.json | 0 .../validators/external-documentation.json | 30 -- .../external-documentation-bad-url.errors | 1 + .../external-documentation-bad-url.json | 14 + .../external-documentation-no-entries.errors} | 1 - .../external-documentation-no-entries.json | 12 + .../external-documentation-valid.errors | 0 .../external-documentation-valid.json | 14 + .../linters/emit-each-invalid-selector.errors | 30 ++ .../linters/emit-each-invalid-selector.json | 210 +++++++++++++ .../emit-each-selector-validator.errors | 30 -- .../linters/emit-each-selector-validator.json | 210 ------------- ...ion-stops-validating-on-core-errors.errors | 2 + ...ion-stops-validating-on-core-errors.smithy | 23 ++ .../paginated/paginated-deeply-nested.errors | 2 + .../paginated/paginated-deeply-nested.json | 78 +++++ .../paginated-invalid.errors} | 20 +- .../paginated-invalid.json} | 296 +----------------- .../paginated/paginated-map-tokens.errors | 2 + .../paginated/paginated-map-tokens.json | 47 +++ .../paginated/paginated-targets.errors | 4 + .../paginated/paginated-targets.json | 57 ++++ .../paginated/paginated-valid-merge.errors | 0 .../paginated/paginated-valid-merge.json | 75 +++++ .../paginated/paginated-valid.errors | 0 .../validators/paginated/paginated-valid.json | 149 +++++++++ .../resource-identifiers-bad-type.errors | 1 + .../resource-identifiers-bad-type.json | 13 + .../resource-identifiers.errors} | 5 +- .../resource-identifiers.json} | 16 +- .../resource-parent-validator.errors | 4 - .../validators/target-validator.errors | 2 - 47 files changed, 821 insertions(+), 610 deletions(-) create mode 100644 smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-invalid-config.errors create mode 100644 smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-invalid-config.json delete mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-auth-definitions.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-invalid-shape-id.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-invalid-shape-id.json create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-auth-definitions.errors rename smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/{ => auth}/auth-trait-must-target-auth-definitions.json (77%) rename smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/{ => auth}/auth-trait-must-target-service-schemes.errors (100%) rename smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/{ => auth}/auth-trait-must-target-service-schemes.json (100%) delete mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation.json create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-bad-url.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-bad-url.json rename smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/{external-documentation.errors => external-documentation/external-documentation-no-entries.errors} (55%) create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-no-entries.json create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-valid.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-valid.json create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-invalid-selector.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-invalid-selector.json create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/model-validation/model-validation-stops-validating-on-core-errors.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/model-validation/model-validation-stops-validating-on-core-errors.smithy create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-deeply-nested.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-deeply-nested.json rename smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/{paginated-trait-test.errors => paginated/paginated-invalid.errors} (51%) rename smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/{paginated-trait-test.json => paginated/paginated-invalid.json} (54%) create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-map-tokens.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-map-tokens.json create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-targets.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-targets.json create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid-merge.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid-merge.json create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid.json create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers-bad-type.errors create mode 100644 smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers-bad-type.json rename smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/{resource-identifier.errors => resource-identifiers/resource-identifiers.errors} (55%) rename smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/{resource-identifier.json => resource-identifiers/resource-identifiers.json} (80%) diff --git a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/clientendpointdiscovery/service-not-configured.json b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/clientendpointdiscovery/service-not-configured.json index 153ddca519d..31ee169e5be 100644 --- a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/clientendpointdiscovery/service-not-configured.json +++ b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/clientendpointdiscovery/service-not-configured.json @@ -95,7 +95,7 @@ "Id": { "target": "smithy.api#String", "traits": { - "aws.api#endpointDiscoveryId": {}, + "aws.api#clientEndpointDiscoveryId": {}, "smithy.api#required": {} } } diff --git a/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-invalid-config.errors b/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-invalid-config.errors new file mode 100644 index 00000000000..b7bdaf090e2 --- /dev/null +++ b/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-invalid-config.errors @@ -0,0 +1 @@ +[ERROR] -: Error creating `StandardOperationVerb` validator: Either verbs or suggestAlternatives must be set when configuring StandardOperationVerb | Model diff --git a/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-invalid-config.json b/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-invalid-config.json new file mode 100644 index 00000000000..9cdc3cf86d5 --- /dev/null +++ b/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-invalid-config.json @@ -0,0 +1,11 @@ +{ + "smithy": "1.0", + "metadata": { + "validators": [ + { + "name": "StandardOperationVerb", + "id": "Pointless" + } + ] + } +} diff --git a/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-validator-test.errors b/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-validator-test.errors index 4a60f88f34c..289d0ed47ef 100644 --- a/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-validator-test.errors +++ b/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-validator-test.errors @@ -12,4 +12,3 @@ [DANGER] ns.foo#DestroyFoo: Operation shape `DestroyFoo` uses a non-standard verb, `Destroy`. Expected one of the following verbs: `Create`, `Delete`, `Update` | WithVerbsAndPrefixes [DANGER] ns.foo#MakeFoo: Operation shape `MakeFoo` uses a non-standard verb, `Make`. Consider using one of the following verbs instead: `Create`, `Generate` | SuggestAlternatives [DANGER] ns.foo#MakeFoo: Operation shape `MakeFoo` uses a non-standard verb, `Make`. Expected one of the following verbs: `Create`, `Delete`, `Update` | WithVerbsAndPrefixes -[ERROR] -: Error creating `StandardOperationVerb` validator: Either verbs or suggestAlternatives must be set when configuring StandardOperationVerb | Model diff --git a/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-validator-test.json b/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-validator-test.json index 75fee2e484c..ea4fdf167a1 100644 --- a/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-validator-test.json +++ b/smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/standard-operation-verb-validator-test.json @@ -43,10 +43,6 @@ }, "metadata": { "validators": [ - { - "name": "StandardOperationVerb", - "id": "Pointless" - }, { "name": "StandardOperationVerb", "id": "WithVerbsAndPrefixes", diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/loader/LoaderUtils.java b/smithy-model/src/main/java/software/amazon/smithy/model/loader/LoaderUtils.java index 6db46d1b25d..83ae57ef033 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/loader/LoaderUtils.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/loader/LoaderUtils.java @@ -95,4 +95,19 @@ static boolean isSameLocation(FromSourceLocation a, FromSourceLocation b) { SourceLocation sb = b.getSourceLocation(); return sa != SourceLocation.NONE && sa.equals(sb); } + + /** + * Checks if a list of validation events contains an ERROR severity. + * + * @param events Events to check. + * @return Returns true if an ERROR event is present. + */ + static boolean containsErrorEvents(List events) { + for (ValidationEvent event : events) { + if (event.getSeverity() == Severity.ERROR) { + return true; + } + } + return false; + } } diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/loader/ModelAssembler.java b/smithy-model/src/main/java/software/amazon/smithy/model/loader/ModelAssembler.java index 3b5dec9d20b..10155c1c047 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/loader/ModelAssembler.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/loader/ModelAssembler.java @@ -600,7 +600,9 @@ private List createModelFiles() { private ValidatedResult validate(Model model, TraitContainer traits, List events) { validateTraits(model.getShapeIds(), traits, events); - if (disableValidation) { + // If ERROR validation events occur while loading, then performing more + // granular semantic validation will only obscure the root cause of errors. + if (disableValidation || LoaderUtils.containsErrorEvents(events)) { return new ValidatedResult<>(model, events); } diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/loader/ModelValidator.java b/smithy-model/src/main/java/software/amazon/smithy/model/loader/ModelValidator.java index d07f38ec462..41ec26b6afe 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/loader/ModelValidator.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/loader/ModelValidator.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import software.amazon.smithy.model.Model; import software.amazon.smithy.model.SourceLocation; @@ -33,7 +34,10 @@ import software.amazon.smithy.model.validation.ValidationEvent; import software.amazon.smithy.model.validation.Validator; import software.amazon.smithy.model.validation.ValidatorFactory; +import software.amazon.smithy.model.validation.validators.ResourceCycleValidator; +import software.amazon.smithy.model.validation.validators.TargetValidator; import software.amazon.smithy.utils.ListUtils; +import software.amazon.smithy.utils.SetUtils; /** * Validates a model, including validators and suppressions loaded from @@ -57,6 +61,12 @@ final class ModelValidator { private static final String EMPTY_REASON = ""; private static final Collection SUPPRESSION_KEYS = ListUtils.of(ID, NAMESPACE, REASON); + /** If these validators fail, then many others will too. Validate these first. */ + private static final Set> CORE_VALIDATORS = SetUtils.of( + TargetValidator.class, + ResourceCycleValidator.class + ); + private final List validators; private final ArrayList events = new ArrayList<>(); private final ValidatorFactory validatorFactory; @@ -71,6 +81,7 @@ private ModelValidator( this.model = model; this.validatorFactory = validatorFactory; this.validators = new ArrayList<>(validators); + this.validators.removeIf(v -> CORE_VALIDATORS.contains(v.getClass())); } /** @@ -95,6 +106,15 @@ private List doValidate() { List assembledValidatorDefinitions = assembleValidatorDefinitions(); assembleValidators(assembledValidatorDefinitions); + // Perform critical validation before other more granular semantic validators. + // If these validators fail, then many other validators will fail as well, + // which will only obscure the root cause. + events.addAll(new TargetValidator().validate(model)); + events.addAll(new ResourceCycleValidator().validate(model)); + if (LoaderUtils.containsErrorEvents(events)) { + return events; + } + List result = validators .parallelStream() .flatMap(validator -> validator.validate(model).stream()) diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/PaginatedIndexTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/PaginatedIndexTest.java index 37c0badd363..c1682f9046f 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/PaginatedIndexTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/PaginatedIndexTest.java @@ -33,7 +33,7 @@ public class PaginatedIndexTest { public void findDirectChildren() { ValidatedResult result = Model.assembler() .addImport(getClass().getResource( - "/software/amazon/smithy/model/errorfiles/validators/paginated-trait-test.json")) + "/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid.json")) .assemble(); Model model = result.getResult().get(); PaginatedIndex index = PaginatedIndex.of(model); @@ -63,7 +63,7 @@ public void findDirectChildren() { public void findIndirectChildren() { ValidatedResult result = Model.assembler() .addImport(getClass().getResource( - "/software/amazon/smithy/model/errorfiles/validators/paginated-trait-test.json")) + "/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid.json")) .assemble(); Model model = result.getResult().get(); PaginatedIndex index = PaginatedIndex.of(model); diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-auth-definitions.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-auth-definitions.errors deleted file mode 100644 index a48800aa79d..00000000000 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-auth-definitions.errors +++ /dev/null @@ -1,2 +0,0 @@ -[ERROR] ns.foo#Invalid1: Error creating trait `auth`: Invalid shape ID: not a shape ID | Model -[ERROR] ns.foo#Invalid2: Error validating trait `auth`.0: Shape ID `smithy.api#String` does not match selector `[trait|authDefinition]` | TraitValue diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-invalid-shape-id.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-invalid-shape-id.errors new file mode 100644 index 00000000000..0d1380748f1 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-invalid-shape-id.errors @@ -0,0 +1 @@ +[ERROR] ns.foo#InvalidShapeId: Error creating trait `auth`: Invalid shape ID: not a shape ID | Model diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-invalid-shape-id.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-invalid-shape-id.json new file mode 100644 index 00000000000..81a7a6982c9 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-invalid-shape-id.json @@ -0,0 +1,11 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#InvalidShapeId": { + "type": "operation", + "traits": { + "smithy.api#auth": ["not a shape ID"] + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-auth-definitions.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-auth-definitions.errors new file mode 100644 index 00000000000..f12a7c45bed --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-auth-definitions.errors @@ -0,0 +1 @@ +[ERROR] ns.foo#Invalid1: Error validating trait `auth`.0: Shape ID `smithy.api#String` does not match selector `[trait|authDefinition]` | TraitValue diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-auth-definitions.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-auth-definitions.json similarity index 77% rename from smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-auth-definitions.json rename to smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-auth-definitions.json index 6400127046d..fcc95d893d3 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-auth-definitions.json +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-auth-definitions.json @@ -14,12 +14,6 @@ } }, "ns.foo#Invalid1": { - "type": "operation", - "traits": { - "smithy.api#auth": ["not a shape ID"] - } - }, - "ns.foo#Invalid2": { "type": "operation", "traits": { "smithy.api#auth": ["smithy.api#String"] diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-service-schemes.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-service-schemes.errors similarity index 100% rename from smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-service-schemes.errors rename to smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-service-schemes.errors diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-service-schemes.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-service-schemes.json similarity index 100% rename from smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth-trait-must-target-service-schemes.json rename to smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/auth/auth-trait-must-target-service-schemes.json diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation.json deleted file mode 100644 index c2cdefa7e94..00000000000 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "smithy": "1.0", - "shapes": { - "ns.foo#Valid": { - "type": "service", - "version": "2017-01-17", - "traits": { - "smithy.api#externalDocumentation": { - "Homepage": "https://www.example.com" - } - } - }, - "ns.foo#Invalid": { - "type": "service", - "version": "2017-01-17", - "traits": { - "smithy.api#externalDocumentation": { - "Homepage": "invalid!" - } - } - }, - "ns.foo#Invalid2": { - "type": "service", - "version": "2017-01-17", - "traits": { - "smithy.api#externalDocumentation": {} - } - } - } -} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-bad-url.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-bad-url.errors new file mode 100644 index 00000000000..8d1c0d51925 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-bad-url.errors @@ -0,0 +1 @@ +[ERROR] ns.foo#Invalid: Error creating trait `externalDocumentation`: Each externalDocumentation value must be a valid URL. Found "invalid!" for name "Homepage" | Model diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-bad-url.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-bad-url.json new file mode 100644 index 00000000000..055de6a5d67 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-bad-url.json @@ -0,0 +1,14 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#Invalid": { + "type": "service", + "version": "2017-01-17", + "traits": { + "smithy.api#externalDocumentation": { + "Homepage": "invalid!" + } + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-no-entries.errors similarity index 55% rename from smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation.errors rename to smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-no-entries.errors index 0d6c917cd80..c4f0671a23a 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-no-entries.errors @@ -1,2 +1 @@ -[ERROR] ns.foo#Invalid: Error creating trait `externalDocumentation`: Each externalDocumentation value must be a valid URL. Found "invalid!" for name "Homepage" | Model [ERROR] ns.foo#Invalid2: Error validating trait `externalDocumentation`: Value provided for `smithy.api#externalDocumentation` must have at least 1 entries, but the provided value only has 0 entries | TraitValue diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-no-entries.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-no-entries.json new file mode 100644 index 00000000000..ab691692a5c --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-no-entries.json @@ -0,0 +1,12 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#Invalid2": { + "type": "service", + "version": "2017-01-17", + "traits": { + "smithy.api#externalDocumentation": {} + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-valid.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-valid.errors new file mode 100644 index 00000000000..e69de29bb2d diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-valid.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-valid.json new file mode 100644 index 00000000000..e1cea45e1f0 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/external-documentation/external-documentation-valid.json @@ -0,0 +1,14 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#Valid": { + "type": "service", + "version": "2017-01-17", + "traits": { + "smithy.api#externalDocumentation": { + "Homepage": "https://www.example.com" + } + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-invalid-selector.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-invalid-selector.errors new file mode 100644 index 00000000000..aefa65daf40 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-invalid-selector.errors @@ -0,0 +1,30 @@ +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near ``: Unexpected selector EOF; expression: | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near ``: Unexpected selector EOF; expression: | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "!": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near `!`: Unexpected selector character: !; expression: ! | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "'foo'": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near `'foo'`: Unexpected selector character: '; expression: 'foo' | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "\"foo\"": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near `"foo"`: Unexpected selector character: "; expression: "foo" | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "invalid": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 8, near ``: Unknown shape type: invalid; expression: invalid | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 2, near `]`: Expected a valid identifier character, but found ']'; expression: [] | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo|]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `]`: Expected a valid identifier character, but found ']'; expression: [foo|] | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[|]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 2, near `|]`: Expected a valid identifier character, but found '|'; expression: [|] | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[a=]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 4, near `]`: Expected a valid identifier character, but found ']'; expression: [a=] | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[a=b": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 5, near ``: Expected: ']', but found '[EOF]'; expression: [a=b | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "string=b": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 7, near `=b`: Unexpected selector character: =; expression: string=b | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo=']": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 8, near ``: Expected ' to close ]; expression: [foo='] | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo=\"]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 8, near ``: Expected " to close ]; expression: [foo="] | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo==value]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `=value]`: Expected a valid identifier character, but found '='; expression: [foo==value] | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo^foo]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `foo]`: Expected: '=', but found 'f'; expression: [foo^foo] | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(:not(string) > list": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 24, near ``: Found '[EOF]', but expected one of the following tokens: ')' ','; expression: :is(:not(string) > list | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "foo -[]->": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 4, near ` -[]->`: Unknown shape type: foo; expression: foo -[]-> | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "foo -[input]->": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 4, near ` -[input]->`: Unknown shape type: foo; expression: foo -[input]-> | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":not": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 5, near ``: Expected: '(', but found '[EOF]'; expression: :not | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":not(": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near ``: Unexpected selector EOF; expression: :not( | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":not()": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `)`: Unexpected selector character: ); expression: :not() | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":not(string": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 12, near ``: Found '[EOF]', but expected one of the following tokens: ')' ','; expression: :not(string | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 4, near ``: Expected: '(', but found '[EOF]'; expression: :is | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 5, near ``: Unexpected selector EOF; expression: :is( | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":nay()": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `)`: Unexpected selector character: ); expression: :nay() | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(string": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 11, near ``: Found '[EOF]', but expected one of the following tokens: ')' ','; expression: :is(string | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(string, ": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 13, near ``: Unexpected selector EOF; expression: :is(string, | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(string, )": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 13, near `)`: Unexpected selector character: ); expression: :is(string, ) | Model +[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(string, :not())": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 18, near `))`: Unexpected selector character: ); expression: :is(string, :not()) | Model diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-invalid-selector.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-invalid-selector.json new file mode 100644 index 00000000000..ae277d94e69 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-invalid-selector.json @@ -0,0 +1,210 @@ +{ + "smithy": "1.0", + "metadata": { + "validators": [ + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "!" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "'foo'" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "\"foo\"" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "invalid" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "[]" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "[foo|]" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "[|]" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "[a=]" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "[a=b" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "string=b" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "[foo=']" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "[foo=\"]" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "[foo==value]" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "[foo^foo]" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":is(:not(string) > list" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "foo -[]->" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": "foo -[input]->" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":not" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":not(" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":not()" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":not(string" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":is" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":is(" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":nay()" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":is(string" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":is(string, " + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":is(string, )" + } + }, + { + "id": "invalid", + "name": "EmitEachSelector", + "configuration": { + "selector": ":is(string, :not())" + } + } + ] + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-selector-validator.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-selector-validator.errors index 6ed101d8733..dfe9e16099d 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-selector-validator.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-selector-validator.errors @@ -96,33 +96,3 @@ [DANGER] other.ns#String: Selector capture matched selector: [id|name='String'] | shapeName [DANGER] other.ns#String: Selector capture matched selector: simpleType | simpleType [NOTE] other.ns#String: The string shape is not connected to from any service shape. | UnreferencedShape -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near ``: Unexpected selector EOF; expression: | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near ``: Unexpected selector EOF; expression: | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "!": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near `!`: Unexpected selector character: !; expression: ! | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "'foo'": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near `'foo'`: Unexpected selector character: '; expression: 'foo' | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "\"foo\"": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 1, near `"foo"`: Unexpected selector character: "; expression: "foo" | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "invalid": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 8, near ``: Unknown shape type: invalid; expression: invalid | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 2, near `]`: Expected a valid identifier character, but found ']'; expression: [] | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo|]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `]`: Expected a valid identifier character, but found ']'; expression: [foo|] | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[|]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 2, near `|]`: Expected a valid identifier character, but found '|'; expression: [|] | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[a=]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 4, near `]`: Expected a valid identifier character, but found ']'; expression: [a=] | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[a=b": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 5, near ``: Expected: ']', but found '[EOF]'; expression: [a=b | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "string=b": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 7, near `=b`: Unexpected selector character: =; expression: string=b | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo=']": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 8, near ``: Expected ' to close ]; expression: [foo='] | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo=\"]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 8, near ``: Expected " to close ]; expression: [foo="] | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo==value]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `=value]`: Expected a valid identifier character, but found '='; expression: [foo==value] | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "[foo^foo]": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `foo]`: Expected: '=', but found 'f'; expression: [foo^foo] | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(:not(string) > list": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 24, near ``: Found '[EOF]', but expected one of the following tokens: ')' ','; expression: :is(:not(string) > list | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "foo -[]->": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 4, near ` -[]->`: Unknown shape type: foo; expression: foo -[]-> | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from "foo -[input]->": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 4, near ` -[input]->`: Unknown shape type: foo; expression: foo -[input]-> | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":not": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 5, near ``: Expected: '(', but found '[EOF]'; expression: :not | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":not(": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near ``: Unexpected selector EOF; expression: :not( | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":not()": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `)`: Unexpected selector character: ); expression: :not() | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":not(string": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 12, near ``: Found '[EOF]', but expected one of the following tokens: ')' ','; expression: :not(string | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 4, near ``: Expected: '(', but found '[EOF]'; expression: :is | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 5, near ``: Unexpected selector EOF; expression: :is( | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":nay()": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 6, near `)`: Unexpected selector character: ); expression: :nay() | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(string": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 11, near ``: Found '[EOF]', but expected one of the following tokens: ')' ','; expression: :is(string | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(string, ": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 13, near ``: Unexpected selector EOF; expression: :is(string, | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(string, )": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 13, near `)`: Unexpected selector character: ); expression: :is(string, ) | Model -[ERROR] -: Error creating `EmitEachSelector` validator: Deserialization error at (/selector): unable to create software.amazon.smithy.model.selector.Selector from ":is(string, :not())": Unable to deserialize Node using fromNode method: Syntax error at line 1 column 18, near `))`: Unexpected selector character: ); expression: :is(string, :not()) | Model diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-selector-validator.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-selector-validator.json index 8d92c9b7ad4..42daab9d390 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-selector-validator.json +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/linters/emit-each-selector-validator.json @@ -144,216 +144,6 @@ }, "metadata": { "validators": [ - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "!" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "'foo'" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "\"foo\"" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "invalid" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "[]" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "[foo|]" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "[|]" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "[a=]" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "[a=b" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "string=b" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "[foo=']" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "[foo=\"]" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "[foo==value]" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "[foo^foo]" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":is(:not(string) > list" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "foo -[]->" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": "foo -[input]->" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":not" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":not(" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":not()" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":not(string" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":is" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":is(" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":nay()" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":is(string" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":is(string, " - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":is(string, )" - } - }, - { - "id": "invalid", - "name": "EmitEachSelector", - "configuration": { - "selector": ":is(string, :not())" - } - }, { "id": "integer", "name": "EmitEachSelector", diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/model-validation/model-validation-stops-validating-on-core-errors.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/model-validation/model-validation-stops-validating-on-core-errors.errors new file mode 100644 index 00000000000..bc877600a0a --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/model-validation/model-validation-stops-validating-on-core-errors.errors @@ -0,0 +1,2 @@ +[ERROR] smithy.example#FooRequest$listVal: member shape targets an unresolved shape `smithy.example#ListOfString` | Target +[ERROR] smithy.example#FooRequest$mapVal: member shape targets an unresolved shape `smithy.example#MapOfInteger` | Target diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/model-validation/model-validation-stops-validating-on-core-errors.smithy b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/model-validation/model-validation-stops-validating-on-core-errors.smithy new file mode 100644 index 00000000000..229d1185c91 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/model-validation/model-validation-stops-validating-on-core-errors.smithy @@ -0,0 +1,23 @@ +namespace smithy.example + +service Example { + version: "1.0.0", + operations: [ + Foo + ] +} + +@http(method: "POST", uri: "/foo") +operation Foo { + input: FooRequest, + output: FooRequest +} + +@xmlName("CustomFooRequest") +structure FooRequest { + @xmlFlattened + listVal: ListOfString, + + @xmlFlattened + mapVal: MapOfInteger +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-deeply-nested.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-deeply-nested.errors new file mode 100644 index 00000000000..1ff66958b89 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-deeply-nested.errors @@ -0,0 +1,2 @@ +[WARNING] ns.foo#DeeplyNestedOutputOperation: paginated trait `items` contains a path with more than two parts, which can make your API cumbersome to use | PaginatedTrait +[WARNING] ns.foo#DeeplyNestedOutputOperation: paginated trait `outputToken` contains a path with more than two parts, which can make your API cumbersome to use | PaginatedTrait diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-deeply-nested.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-deeply-nested.json new file mode 100644 index 00000000000..4168fc97cb8 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-deeply-nested.json @@ -0,0 +1,78 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#Service": { + "type": "service", + "version": "2019-06-27", + "operations": [ + { + "target": "ns.foo#DeeplyNestedOutputOperation" + } + ] + }, + "ns.foo#DeeplyNestedOutputOperation": { + "type": "operation", + "input": { + "target": "ns.foo#ValidInput" + }, + "output": { + "target": "ns.foo#DeeplyNestedOutput" + }, + "traits": { + "smithy.api#readonly": {}, + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "output.result.nextToken", + "items": "output.result.items" + } + } + }, + "ns.foo#ValidInput": { + "type": "structure", + "members": { + "nextToken": { + "target": "smithy.api#String" + }, + "pageSize": { + "target": "smithy.api#Integer" + } + } + }, + "ns.foo#DeeplyNestedOutput": { + "type": "structure", + "members": { + "output": { + "target": "ns.foo#ValidWrappedOutput" + } + } + }, + "ns.foo#ValidWrappedOutput": { + "type": "structure", + "members": { + "result": { + "target": "ns.foo#ValidOutput" + } + } + }, + "ns.foo#ValidOutput": { + "type": "structure", + "members": { + "nextToken": { + "target": "smithy.api#String" + }, + "items": { + "target": "ns.foo#StringList", + "traits": { + "smithy.api#required": {} + } + } + } + }, + "ns.foo#StringList": { + "type": "list", + "member": { + "target": "smithy.api#String" + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated-trait-test.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-invalid.errors similarity index 51% rename from smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated-trait-test.errors rename to smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-invalid.errors index 8154ebaf558..df47c198d7b 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated-trait-test.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-invalid.errors @@ -7,20 +7,12 @@ [ERROR] ns.foo#Invalid4: paginated trait `inputToken` member `nextToken` must not be required | PaginatedTrait [ERROR] ns.foo#Invalid4: paginated trait `outputToken` member `nextToken` must not be required | PaginatedTrait [WARNING] ns.foo#Invalid4: paginated trait `pageSize` member `pageSize` should not be required | PaginatedTrait -[ERROR] ns.foo#Invalid6: paginated trait `pageSize` member `Invalid6Input` targets a string shape, but must target one of the following: [`integer`] | PaginatedTrait -[ERROR] ns.foo#Invalid7: paginated trait `items` member `Invalid7Input` targets a string shape, but must target one of the following: [`list`, `map`] | PaginatedTrait -[ERROR] ns.foo#Invalid8: paginated trait `items` targets a member `items` that does not exist | PaginatedTrait -[ERROR] ns.foo#Invalid8: paginated trait `outputToken` targets a member `missing` that does not exist | PaginatedTrait +[ERROR] ns.foo#Invalid5: paginated trait `pageSize` member `Invalid5Input` targets a string shape, but must target one of the following: [`integer`] | PaginatedTrait +[ERROR] ns.foo#Invalid6: paginated trait `items` member `Invalid6Input` targets a string shape, but must target one of the following: [`list`, `map`] | PaginatedTrait +[ERROR] ns.foo#Invalid7: paginated trait `items` targets a member `items` that does not exist | PaginatedTrait +[ERROR] ns.foo#Invalid7: paginated trait `outputToken` targets a member `missing` that does not exist | PaginatedTrait [ERROR] ns.foo#InvalidNoOutput: paginated operations require an output | PaginatedTrait -[ERROR] ns.foo#UnresolvedInput$nextToken: member shape targets an unresolved shape `ns.foo#Missing` | Target -[ERROR] ns.foo#UnresolvedInput$pageSize: member shape targets an unresolved shape `ns.foo#Missing` | Target -[ERROR] ns.foo#UnresolvedOutput$items: member shape targets an unresolved shape `ns.foo#Missing` | Target -[ERROR] ns.foo#UnresolvedOutput$nextToken: member shape targets an unresolved shape `ns.foo#Missing` | Target -[ERROR] ns.foo#Invalid9: When bound within the `ns.foo#Service` service, paginated trait `inputToken` is not configured | PaginatedTrait -[ERROR] ns.foo#Invalid9: When bound within the `ns.foo#Service` service, paginated trait `outputToken` is not configured | PaginatedTrait -[WARNING] ns.foo#DeeplyNestedOutputOperation: paginated trait `items` contains a path with more than two parts, which can make your API cumbersome to use | PaginatedTrait -[WARNING] ns.foo#DeeplyNestedOutputOperation: paginated trait `outputToken` contains a path with more than two parts, which can make your API cumbersome to use | PaginatedTrait +[ERROR] ns.foo#Invalid8: When bound within the `ns.foo#Service` service, paginated trait `inputToken` is not configured | PaginatedTrait +[ERROR] ns.foo#Invalid8: When bound within the `ns.foo#Service` service, paginated trait `outputToken` is not configured | PaginatedTrait [ERROR] ns.foo#InvalidNestedInput: paginated trait `inputToken` does not allow path values | PaginatedTrait [ERROR] ns.foo#InvalidNestedInput: paginated trait `pageSize` does not allow path values | PaginatedTrait -[DANGER] ns.foo#MapTokens: paginated trait `inputToken` member `MapTokenInputOutput` targets a map shape, but this is not recommended. One of [`string`] SHOULD be targeted. | PaginatedTrait -[DANGER] ns.foo#MapTokens: paginated trait `outputToken` member `MapTokenInputOutput` targets a map shape, but this is not recommended. One of [`string`] SHOULD be targeted. | PaginatedTrait diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated-trait-test.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-invalid.json similarity index 54% rename from smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated-trait-test.json rename to smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-invalid.json index ae65d1e8c2b..9904c042334 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated-trait-test.json +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-invalid.json @@ -5,15 +5,6 @@ "type": "service", "version": "2019-06-27", "operations": [ - { - "target": "ns.foo#Valid1" - }, - { - "target": "ns.foo#Valid2" - }, - { - "target": "ns.foo#Valid3" - }, { "target": "ns.foo#Invalid1" }, @@ -38,143 +29,14 @@ { "target": "ns.foo#Invalid8" }, - { - "target": "ns.foo#Invalid9" - }, - { - "target": "ns.foo#ValidNestedOutputOperation" - }, - { - "target": "ns.foo#DeeplyNestedOutputOperation" - }, { "target": "ns.foo#InvalidNoOutput" }, { "target": "ns.foo#InvalidNestedInput" - }, - { - "target": "ns.foo#MapTokens" } ] }, - "ns.foo#Valid1": { - "type": "operation", - "input": { - "target": "ns.foo#ValidInput" - }, - "output": { - "target": "ns.foo#ValidOutput" - }, - "traits": { - "smithy.api#readonly": {}, - "smithy.api#paginated": { - "inputToken": "nextToken", - "outputToken": "nextToken", - "items": "items" - } - } - }, - "ns.foo#Valid2": { - "type": "operation", - "input": { - "target": "ns.foo#ValidInput" - }, - "output": { - "target": "ns.foo#ValidOutput" - }, - "traits": { - "smithy.api#readonly": {}, - "smithy.api#paginated": { - "inputToken": "nextToken", - "outputToken": "nextToken", - "items": "items", - "pageSize": "pageSize" - } - } - }, - "ns.foo#Valid3": { - "type": "operation", - "input": { - "target": "ns.foo#ValidInput3" - }, - "output": { - "target": "ns.foo#ValidOutput3" - }, - "traits": { - "smithy.api#readonly": {}, - "smithy.api#paginated": { - "inputToken": "nextToken", - "outputToken": "nextToken" - } - } - }, - "ns.foo#ValidNestedOutputOperation": { - "type": "operation", - "input": { - "target": "ns.foo#ValidInput" - }, - "output": { - "target": "ns.foo#ValidWrappedOutput" - }, - "traits": { - "smithy.api#readonly": {}, - "smithy.api#paginated": { - "inputToken": "nextToken", - "outputToken": "result.nextToken", - "items": "result.items" - } - } - }, - "ns.foo#DeeplyNestedOutputOperation": { - "type": "operation", - "input": { - "target": "ns.foo#ValidInput" - }, - "output": { - "target": "ns.foo#DeeplyNestedOutput" - }, - "traits": { - "smithy.api#readonly": {}, - "smithy.api#paginated": { - "inputToken": "nextToken", - "outputToken": "output.result.nextToken", - "items": "output.result.items" - } - } - }, - "ns.foo#DeeplyNestedOutput": { - "type": "structure", - "members": { - "output": { - "target": "ns.foo#ValidWrappedOutput" - } - } - }, - "ns.foo#ValidWrappedOutput": { - "type": "structure", - "members": { - "result": { - "target": "ns.foo#ValidOutput" - } - } - }, - "ns.foo#ValidInput3": { - "type": "structure", - "members": { - "nextToken": { - "target": "smithy.api#String" - } - } - }, - "ns.foo#ValidOutput3": { - "type": "structure", - "members": { - "nextToken": { - "target": "smithy.api#String" - } - } - }, "ns.foo#Invalid1": { "type": "operation", "output": { @@ -328,50 +190,7 @@ "ns.foo#Invalid5": { "type": "operation", "input": { - "target": "ns.foo#UnresolvedInput" - }, - "output": { - "target": "ns.foo#UnresolvedOutput" - }, - "traits": { - "smithy.api#readonly": {}, - "smithy.api#paginated": { - "inputToken": "nextToken", - "outputToken": "nextToken", - "items": "items", - "pageSize": "pageSize" - } - } - }, - "ns.foo#UnresolvedInput": { - "type": "structure", - "members": { - "nextToken": { - "target": "ns.foo#Missing" - }, - "pageSize": { - "target": "ns.foo#Missing" - } - } - }, - "ns.foo#UnresolvedOutput": { - "type": "structure", - "members": { - "nextToken": { - "target": "ns.foo#Missing" - }, - "items": { - "target": "ns.foo#Missing", - "traits": { - "smithy.api#required": {} - } - } - } - }, - "ns.foo#Invalid6": { - "type": "operation", - "input": { - "target": "ns.foo#Invalid6Input" + "target": "ns.foo#Invalid5Input" }, "output": { "target": "ns.foo#ValidOutput" @@ -386,7 +205,7 @@ } } }, - "ns.foo#Invalid6Input": { + "ns.foo#Invalid5Input": { "type": "structure", "members": { "nextToken": { @@ -397,13 +216,13 @@ } } }, - "ns.foo#Invalid7": { + "ns.foo#Invalid6": { "type": "operation", "input": { "target": "ns.foo#ValidInput" }, "output": { - "target": "ns.foo#Invalid7Input" + "target": "ns.foo#Invalid6Input" }, "traits": { "smithy.api#readonly": {}, @@ -415,7 +234,7 @@ } } }, - "ns.foo#Invalid7Input": { + "ns.foo#Invalid6Input": { "type": "structure", "members": { "nextToken": { @@ -429,13 +248,13 @@ } } }, - "ns.foo#Invalid8": { + "ns.foo#Invalid7": { "type": "operation", "input": { "target": "ns.foo#ValidInput" }, "output": { - "target": "ns.foo#Invalid8Output" + "target": "ns.foo#Invalid7Output" }, "traits": { "smithy.api#readonly": {}, @@ -447,7 +266,7 @@ } } }, - "ns.foo#Invalid8Output": { + "ns.foo#Invalid7Output": { "type": "structure", "members": { "nextToken": { @@ -455,7 +274,7 @@ } } }, - "ns.foo#Invalid9": { + "ns.foo#Invalid8": { "type": "operation", "input": { "target": "ns.foo#ValidInput" @@ -528,103 +347,6 @@ }, "ns.foo#Number": { "type": "integer" - }, - "ns.foo#Service2": { - "type": "service", - "version": "2019-06-27", - "resources": [ - { - "target": "ns.foo#Resource" - } - ], - "traits": { - "smithy.api#paginated": { - "inputToken": "nextToken", - "outputToken": "nextToken", - "pageSize": "pageSize" - } - } - }, - "ns.foo#Resource": { - "type": "resource", - "identifiers": { - "foo": { - "target": "smithy.api#String" - } - }, - "list": { - "target": "ns.foo#ListResources" - } - }, - "ns.foo#ListResources": { - "type": "operation", - "input": { - "target": "ns.foo#ListResourcesInput" - }, - "output": { - "target": "ns.foo#ListResourcesOutput" - }, - "traits": { - "smithy.api#readonly": {}, - "smithy.api#paginated": { - "items": "items" - } - } - }, - "ns.foo#ListResourcesInput": { - "type": "structure", - "members": { - "nextToken": { - "target": "smithy.api#String" - }, - "pageSize": { - "target": "smithy.api#Integer" - } - } - }, - "ns.foo#ListResourcesOutput": { - "type": "structure", - "members": { - "nextToken": { - "target": "smithy.api#String" - }, - "items": { - "target": "ns.foo#StringList" - } - } - }, - "ns.foo#MapTokens": { - "type": "operation", - "input": { - "target": "ns.foo#MapTokenInputOutput" - }, - "output": { - "target": "ns.foo#MapTokenInputOutput" - }, - "traits": { - "smithy.api#readonly": {}, - "smithy.api#paginated": { - "inputToken": "nextToken", - "outputToken": "nextToken" - } - } - }, - "ns.foo#MapTokenInputOutput": { - "type": "structure", - "members": { - "nextToken": { - "target": "ns.foo#StringMap" - } - } - }, - "ns.foo#StringMap": { - "type": "map", - "key": { - "target": "smithy.api#String" - }, - "value": { - "target": "smithy.api#String" - } } } } diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-map-tokens.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-map-tokens.errors new file mode 100644 index 00000000000..afa10e5b2d7 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-map-tokens.errors @@ -0,0 +1,2 @@ +[DANGER] ns.foo#MapTokens: paginated trait `inputToken` member `MapTokenInputOutput` targets a map shape, but this is not recommended. One of [`string`] SHOULD be targeted. | PaginatedTrait +[DANGER] ns.foo#MapTokens: paginated trait `outputToken` member `MapTokenInputOutput` targets a map shape, but this is not recommended. One of [`string`] SHOULD be targeted. | PaginatedTrait diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-map-tokens.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-map-tokens.json new file mode 100644 index 00000000000..77dd46f57fc --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-map-tokens.json @@ -0,0 +1,47 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#Service2": { + "type": "service", + "version": "2019-06-27", + "operations": [ + { + "target": "ns.foo#MapTokens" + } + ] + }, + "ns.foo#MapTokens": { + "type": "operation", + "input": { + "target": "ns.foo#MapTokenInputOutput" + }, + "output": { + "target": "ns.foo#MapTokenInputOutput" + }, + "traits": { + "smithy.api#readonly": {}, + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "nextToken" + } + } + }, + "ns.foo#MapTokenInputOutput": { + "type": "structure", + "members": { + "nextToken": { + "target": "ns.foo#StringMap" + } + } + }, + "ns.foo#StringMap": { + "type": "map", + "key": { + "target": "smithy.api#String" + }, + "value": { + "target": "smithy.api#String" + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-targets.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-targets.errors new file mode 100644 index 00000000000..beff9cd1921 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-targets.errors @@ -0,0 +1,4 @@ +[ERROR] ns.foo#UnresolvedInput$nextToken: member shape targets an unresolved shape `ns.foo#Missing` | Target +[ERROR] ns.foo#UnresolvedInput$pageSize: member shape targets an unresolved shape `ns.foo#Missing` | Target +[ERROR] ns.foo#UnresolvedOutput$items: member shape targets an unresolved shape `ns.foo#Missing` | Target +[ERROR] ns.foo#UnresolvedOutput$nextToken: member shape targets an unresolved shape `ns.foo#Missing` | Target diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-targets.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-targets.json new file mode 100644 index 00000000000..253e5b583fb --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-targets.json @@ -0,0 +1,57 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#Service": { + "type": "service", + "version": "2019-06-27", + "operations": [ + { + "target": "ns.foo#UnresolvedTargets" + } + ] + }, + "ns.foo#UnresolvedTargets": { + "type": "operation", + "input": { + "target": "ns.foo#UnresolvedInput" + }, + "output": { + "target": "ns.foo#UnresolvedOutput" + }, + "traits": { + "smithy.api#readonly": {}, + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "nextToken", + "items": "items", + "pageSize": "pageSize" + } + } + }, + "ns.foo#UnresolvedInput": { + "type": "structure", + "members": { + "nextToken": { + "target": "ns.foo#Missing" + }, + "pageSize": { + "target": "ns.foo#Missing" + } + } + }, + "ns.foo#UnresolvedOutput": { + "type": "structure", + "members": { + "nextToken": { + "target": "ns.foo#Missing" + }, + "items": { + "target": "ns.foo#Missing", + "traits": { + "smithy.api#required": {} + } + } + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid-merge.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid-merge.errors new file mode 100644 index 00000000000..e69de29bb2d diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid-merge.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid-merge.json new file mode 100644 index 00000000000..3e735f43c7a --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid-merge.json @@ -0,0 +1,75 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#Service2": { + "type": "service", + "version": "2019-06-27", + "resources": [ + { + "target": "ns.foo#Resource" + } + ], + "traits": { + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "nextToken", + "pageSize": "pageSize" + } + } + }, + "ns.foo#Resource": { + "type": "resource", + "identifiers": { + "foo": { + "target": "smithy.api#String" + } + }, + "list": { + "target": "ns.foo#ListResources" + } + }, + "ns.foo#ListResources": { + "type": "operation", + "input": { + "target": "ns.foo#ListResourcesInput" + }, + "output": { + "target": "ns.foo#ListResourcesOutput" + }, + "traits": { + "smithy.api#readonly": {}, + "smithy.api#paginated": { + "items": "items" + } + } + }, + "ns.foo#ListResourcesInput": { + "type": "structure", + "members": { + "nextToken": { + "target": "smithy.api#String" + }, + "pageSize": { + "target": "smithy.api#Integer" + } + } + }, + "ns.foo#ListResourcesOutput": { + "type": "structure", + "members": { + "nextToken": { + "target": "smithy.api#String" + }, + "items": { + "target": "ns.foo#StringList" + } + } + }, + "ns.foo#StringList": { + "type": "list", + "member": { + "target": "smithy.api#String" + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid.errors new file mode 100644 index 00000000000..e69de29bb2d diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid.json new file mode 100644 index 00000000000..2619e398838 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/paginated/paginated-valid.json @@ -0,0 +1,149 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#Service": { + "type": "service", + "version": "2019-06-27", + "operations": [ + { + "target": "ns.foo#Valid1" + }, + { + "target": "ns.foo#Valid2" + }, + { + "target": "ns.foo#Valid3" + }, + { + "target": "ns.foo#ValidNestedOutputOperation" + } + ] + }, + "ns.foo#Valid1": { + "type": "operation", + "input": { + "target": "ns.foo#ValidInput" + }, + "output": { + "target": "ns.foo#ValidOutput" + }, + "traits": { + "smithy.api#readonly": {}, + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "nextToken", + "items": "items" + } + } + }, + "ns.foo#Valid2": { + "type": "operation", + "input": { + "target": "ns.foo#ValidInput" + }, + "output": { + "target": "ns.foo#ValidOutput" + }, + "traits": { + "smithy.api#readonly": {}, + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "nextToken", + "items": "items", + "pageSize": "pageSize" + } + } + }, + "ns.foo#Valid3": { + "type": "operation", + "input": { + "target": "ns.foo#ValidInput3" + }, + "output": { + "target": "ns.foo#ValidOutput3" + }, + "traits": { + "smithy.api#readonly": {}, + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "nextToken" + } + } + }, + "ns.foo#ValidNestedOutputOperation": { + "type": "operation", + "input": { + "target": "ns.foo#ValidInput" + }, + "output": { + "target": "ns.foo#ValidWrappedOutput" + }, + "traits": { + "smithy.api#readonly": {}, + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "result.nextToken", + "items": "result.items" + } + } + }, + "ns.foo#ValidWrappedOutput": { + "type": "structure", + "members": { + "result": { + "target": "ns.foo#ValidOutput" + } + } + }, + "ns.foo#ValidInput3": { + "type": "structure", + "members": { + "nextToken": { + "target": "smithy.api#String" + } + } + }, + "ns.foo#ValidOutput3": { + "type": "structure", + "members": { + "nextToken": { + "target": "smithy.api#String" + } + } + }, + "ns.foo#ValidInput": { + "type": "structure", + "members": { + "nextToken": { + "target": "smithy.api#String" + }, + "pageSize": { + "target": "smithy.api#Integer" + } + } + }, + "ns.foo#ValidOutput": { + "type": "structure", + "members": { + "nextToken": { + "target": "smithy.api#String" + }, + "items": { + "target": "ns.foo#StringList", + "traits": { + "smithy.api#required": {} + } + } + } + }, + "ns.foo#StringList": { + "type": "list", + "member": { + "target": "smithy.api#String" + } + }, + "smithy.api#String": { + "type": "string" + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers-bad-type.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers-bad-type.errors new file mode 100644 index 00000000000..4bf2de272ce --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers-bad-type.errors @@ -0,0 +1 @@ +[ERROR] ns.foo#BadTarget: resource shape `identifier` relationships must target a string shape, but found (float: `smithy.api#Float`) | Target diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers-bad-type.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers-bad-type.json new file mode 100644 index 00000000000..52caea50b7e --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers-bad-type.json @@ -0,0 +1,13 @@ +{ + "smithy": "1.0", + "shapes": { + "ns.foo#BadTarget": { + "type": "resource", + "identifiers": { + "id": { + "target": "smithy.api#Float" + } + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifier.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers.errors similarity index 55% rename from smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifier.errors rename to smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers.errors index 73e68c628a6..933e307beca 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifier.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers.errors @@ -1,3 +1,2 @@ -[ERROR] ns.foo#Invalid1: resource shape `identifier` relationships must target a string shape, but found (float: `smithy.api#Float`) | Target -[ERROR] ns.foo#Invalid2: This resource is bound as a child of `ns.foo#Valid1`, but it is invalid because its `identifiers` property is missing the following identifiers that are defined in `ns.foo#Valid1`: [b] | ResourceIdentifier -[ERROR] ns.foo#Invalid3: The `identifiers` property of this resource is incompatible with its binding to `ns.foo#Valid1`: expected the `b` member to target `smithy.api#String`, but found a target of `ns.foo#MyString` | ResourceIdentifier +[ERROR] ns.foo#Invalid1: This resource is bound as a child of `ns.foo#Valid1`, but it is invalid because its `identifiers` property is missing the following identifiers that are defined in `ns.foo#Valid1`: [b] | ResourceIdentifier +[ERROR] ns.foo#Invalid2: The `identifiers` property of this resource is incompatible with its binding to `ns.foo#Valid1`: expected the `b` member to target `smithy.api#String`, but found a target of `ns.foo#MyString` | ResourceIdentifier diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifier.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers.json similarity index 80% rename from smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifier.json rename to smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers.json index 411de954198..80e904d28d9 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifier.json +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-identifiers/resource-identifiers.json @@ -1,14 +1,6 @@ { "smithy": "1.0", "shapes": { - "ns.foo#Invalid1": { - "type": "resource", - "identifiers": { - "id": { - "target": "smithy.api#Float" - } - } - }, "ns.foo#Valid1": { "type": "resource", "identifiers": { @@ -21,14 +13,14 @@ }, "resources": [ { - "target": "ns.foo#Invalid2" + "target": "ns.foo#Invalid1" }, { - "target": "ns.foo#Invalid3" + "target": "ns.foo#Invalid2" } ] }, - "ns.foo#Invalid2": { + "ns.foo#Invalid1": { "type": "resource", "identifiers": { "a": { @@ -36,7 +28,7 @@ } } }, - "ns.foo#Invalid3": { + "ns.foo#Invalid2": { "type": "resource", "identifiers": { "a": { diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-parent-validator.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-parent-validator.errors index 4e0bcea7e19..48fc7e4625e 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-parent-validator.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/resource-parent-validator.errors @@ -2,8 +2,4 @@ [ERROR] ns.foo#CycleB: Circular resource hierarchy found: ns.foo#CycleB -> ns.foo#CycleC -> ns.foo#CycleA -> ns.foo#CycleB | ResourceCycle [ERROR] ns.foo#CycleC: Circular resource hierarchy found: ns.foo#CycleC -> ns.foo#CycleA -> ns.foo#CycleB -> ns.foo#CycleC | ResourceCycle [ERROR] ns.foo#InvalidResourceBindingType: resource shape `resource` relationships must target a resource shape, but found (string: `smithy.api#String`) | Target -[ERROR] ns.foo#InvalidSelfResourceBinding: A resource can appear only once in an entire service closure. This resource is illegally bound into the `ns.foo#MyService` service closure from multiple shapes: [`ns.foo#InvalidSelfResourceBinding`, `ns.foo#MyService`] | SingleResourceBinding [ERROR] ns.foo#InvalidSelfResourceBinding: Circular resource hierarchy found: ns.foo#InvalidSelfResourceBinding -> ns.foo#InvalidSelfResourceBinding | ResourceCycle -[NOTE] ns.foo#CycleA: The resource shape is not connected to from any service shape. | UnreferencedShape -[NOTE] ns.foo#CycleB: The resource shape is not connected to from any service shape. | UnreferencedShape -[NOTE] ns.foo#CycleC: The resource shape is not connected to from any service shape. | UnreferencedShape diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/target-validator.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/target-validator.errors index ccad42b96a5..0b448b86ca8 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/target-validator.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/target-validator.errors @@ -22,5 +22,3 @@ [ERROR] ns.foo#InvalidResourceLifecycle: Resource update lifecycle operation must target an operation, but found (integer: `ns.foo#Integer`) | Target [ERROR] ns.foo#InvalidResourceLifecycle: resource shape `operation` relationships must target a operation shape, but found (integer: `ns.foo#Integer`) | Target [ERROR] ns.foo#InvalidTraitReference$member: Found a MEMBER_TARGET reference to trait definition `ns.foo#fooTrait`. Trait definitions cannot be targeted by members or referenced by shapes in any other context other than applying them as traits. | Target -[NOTE] ns.foo#String: Shape name `ns.foo#String` conflicts with `another.ns#String` in the `ns.foo#MyService` service closure. Shapes in the closure of a service should have case-insensitively unique names regardless of their namespaces. Use the `rename` property of the service to disambiguate shape names. | Service -[NOTE] another.ns#String: Shape name `another.ns#String` conflicts with `ns.foo#String` in the `ns.foo#MyService` service closure. Shapes in the closure of a service should have case-insensitively unique names regardless of their namespaces. Use the `rename` property of the service to disambiguate shape names. | Service