diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/DisableConditionKeyInferenceTrait.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/DisableConditionKeyInferenceTrait.java index 8aa1ebaf449..6e4bf051e07 100644 --- a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/DisableConditionKeyInferenceTrait.java +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/DisableConditionKeyInferenceTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.aws.iam.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.AnnotationTrait; @@ -25,12 +26,12 @@ public final class DisableConditionKeyInferenceTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("aws.iam#disableConditionKeyInference"); - public DisableConditionKeyInferenceTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public DisableConditionKeyInferenceTrait(ObjectNode node) { + super(ID, node); } public DisableConditionKeyInferenceTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/ControlPlaneTrait.java b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/ControlPlaneTrait.java index 463fbc2889b..2e4ae3a6d07 100644 --- a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/ControlPlaneTrait.java +++ b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/ControlPlaneTrait.java @@ -15,19 +15,20 @@ package software.amazon.smithy.aws.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.AnnotationTrait; public final class ControlPlaneTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("aws.api#controlPlane"); - public ControlPlaneTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public ControlPlaneTrait(ObjectNode node) { + super(ID, node); } public ControlPlaneTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/DataPlaneTrait.java b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/DataPlaneTrait.java index 6ef0c0ed8b8..417349a4ed0 100644 --- a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/DataPlaneTrait.java +++ b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/DataPlaneTrait.java @@ -15,19 +15,20 @@ package software.amazon.smithy.aws.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.AnnotationTrait; public final class DataPlaneTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("aws.api#dataPlane"); - public DataPlaneTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public DataPlaneTrait(ObjectNode node) { + super(ID, node); } public DataPlaneTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/auth/UnsignedPayloadTrait.java b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/auth/UnsignedPayloadTrait.java index 49b86d2c52e..0092a6ed0d5 100644 --- a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/auth/UnsignedPayloadTrait.java +++ b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/auth/UnsignedPayloadTrait.java @@ -15,8 +15,8 @@ package software.amazon.smithy.aws.traits.auth; -import software.amazon.smithy.model.FromSourceLocation; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.AnnotationTrait; @@ -26,12 +26,12 @@ public final class UnsignedPayloadTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("aws.auth#unsignedPayload"); - public UnsignedPayloadTrait(FromSourceLocation sourceLocation) { - super(ID, sourceLocation.getSourceLocation()); + public UnsignedPayloadTrait(ObjectNode node) { + super(ID, node); } public UnsignedPayloadTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/clientendpointdiscovery/ClientEndpointDiscoveryIdTrait.java b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/clientendpointdiscovery/ClientEndpointDiscoveryIdTrait.java index 735c00b8ec5..a5c346e73cb 100644 --- a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/clientendpointdiscovery/ClientEndpointDiscoveryIdTrait.java +++ b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/clientendpointdiscovery/ClientEndpointDiscoveryIdTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.aws.traits.clientendpointdiscovery; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.AnnotationTrait; @@ -26,12 +27,12 @@ public final class ClientEndpointDiscoveryIdTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("aws.api#clientEndpointDiscoveryId"); - public ClientEndpointDiscoveryIdTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public ClientEndpointDiscoveryIdTrait(ObjectNode node) { + super(ID, node); } public ClientEndpointDiscoveryIdTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/protocols/AwsQueryTrait.java b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/protocols/AwsQueryTrait.java index 8bed6a36ef0..868cf198075 100644 --- a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/protocols/AwsQueryTrait.java +++ b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/protocols/AwsQueryTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.aws.traits.protocols; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.AnnotationTrait; @@ -29,12 +30,12 @@ public final class AwsQueryTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("aws.protocols#awsQuery"); - public AwsQueryTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public AwsQueryTrait(ObjectNode node) { + super(ID, node); } public AwsQueryTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/protocols/Ec2QueryTrait.java b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/protocols/Ec2QueryTrait.java index d91da13ca73..db471db6b57 100644 --- a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/protocols/Ec2QueryTrait.java +++ b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/protocols/Ec2QueryTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.aws.traits.protocols; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.AnnotationTrait; @@ -30,12 +31,12 @@ public final class Ec2QueryTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("aws.protocols#ec2Query"); - public Ec2QueryTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public Ec2QueryTrait(ObjectNode node) { + super(ID, node); } public Ec2QueryTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-build/src/test/java/software/amazon/smithy/build/transforms/ExcludeTraitsTest.java b/smithy-build/src/test/java/software/amazon/smithy/build/transforms/ExcludeTraitsTest.java index 3b6dc0ffaca..2aec00cd796 100644 --- a/smithy-build/src/test/java/software/amazon/smithy/build/transforms/ExcludeTraitsTest.java +++ b/smithy-build/src/test/java/software/amazon/smithy/build/transforms/ExcludeTraitsTest.java @@ -37,7 +37,7 @@ public class ExcludeTraitsTest { public void removesTraitsInList() { StringShape stringShape = StringShape.builder() .id("ns.foo#baz") - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .addTrait(new DocumentationTrait("docs", SourceLocation.NONE)) .build(); Model model = Model.assembler() diff --git a/smithy-build/src/test/java/software/amazon/smithy/build/transforms/IncludeTraitsTest.java b/smithy-build/src/test/java/software/amazon/smithy/build/transforms/IncludeTraitsTest.java index 7ca0b706fa7..3a972b67157 100644 --- a/smithy-build/src/test/java/software/amazon/smithy/build/transforms/IncludeTraitsTest.java +++ b/smithy-build/src/test/java/software/amazon/smithy/build/transforms/IncludeTraitsTest.java @@ -64,7 +64,7 @@ public void removesTraitsNotInList() { public void includesBuiltinTraits() { StringShape stringShape = StringShape.builder() .id("ns.foo#baz") - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .addTrait(new DocumentationTrait("docs", SourceLocation.NONE)) .build(); Model model = Model.assembler() diff --git a/smithy-diff/src/test/java/software/amazon/smithy/diff/DifferencesTest.java b/smithy-diff/src/test/java/software/amazon/smithy/diff/DifferencesTest.java index ffa558d8a5c..5f21af59437 100644 --- a/smithy-diff/src/test/java/software/amazon/smithy/diff/DifferencesTest.java +++ b/smithy-diff/src/test/java/software/amazon/smithy/diff/DifferencesTest.java @@ -85,7 +85,7 @@ public void detectsChangedShapes() { Shape shape1 = StringShape.builder().id("foo.bar#Baz").build(); Shape shape2 = StringShape.builder() .id("foo.bar#Baz") - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model previous = Model.assembler().addShape(shape1).assemble().unwrap(); Model current = Model.assembler().addShape(shape2).assemble().unwrap(); diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/AnnotationTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/AnnotationTrait.java index 215dbecae2e..aad24f7cea7 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/AnnotationTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/AnnotationTrait.java @@ -15,7 +15,7 @@ package software.amazon.smithy.model.traits; -import java.util.Collections; +import java.util.Objects; import java.util.function.Function; import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.node.ExpectationNotMetException; @@ -26,27 +26,65 @@ /** * Trait implementation for traits that are an empty object. */ -public abstract class AnnotationTrait extends AbstractTrait { - public AnnotationTrait(ShapeId id, SourceLocation sourceLocation) { - super(id, sourceLocation); +public abstract class AnnotationTrait implements Trait { + + private final ShapeId id; + private final ObjectNode node; + + public AnnotationTrait(ShapeId id, ObjectNode node) { + this.id = Objects.requireNonNull(id); + this.node = Objects.requireNonNull(node); + } + + @Override + public final ShapeId toShapeId() { + return id; + } + + @Override + public final Node toNode() { + return node; + } + + @Override + public final SourceLocation getSourceLocation() { + return node.getSourceLocation(); } @Override - protected final Node createNode() { - return new ObjectNode(Collections.emptyMap(), getSourceLocation()); + public int hashCode() { + return toShapeId().hashCode() * 17 + node.hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null || other.getClass() != getClass()) { + return false; + } + + if (this == other) { + return true; + } + + Trait b = (Trait) other; + if (!toShapeId().equals(b.toShapeId())) { + return false; + } + + return node.equals(b.toNode()); } /** * Trait provider that expects a boolean value of true. */ public static class Provider extends AbstractTrait.Provider { - private final Function traitFactory; + private final Function traitFactory; /** * @param id ID of the trait being created. * @param traitFactory Factory function used to create the trait. */ - public Provider(ShapeId id, Function traitFactory) { + public Provider(ShapeId id, Function traitFactory) { super(id); this.traitFactory = traitFactory; } @@ -54,7 +92,7 @@ public Provider(ShapeId id, Function traitFactory) { @Override public T createTrait(ShapeId id, Node value) { if (value.isObjectNode()) { - return traitFactory.apply(value.getSourceLocation()); + return traitFactory.apply(value.expectObjectNode()); } throw new ExpectationNotMetException(String.format( diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/BoxTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/BoxTrait.java index 2e6bc3a3518..98a8e1242d8 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/BoxTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/BoxTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -24,12 +25,12 @@ public final class BoxTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#box"); - public BoxTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public BoxTrait(ObjectNode node) { + super(ID, node); } public BoxTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/EventHeaderTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/EventHeaderTrait.java index e126183ce8c..565e7fc7a31 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/EventHeaderTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/EventHeaderTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -27,12 +28,12 @@ public final class EventHeaderTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#eventHeader"); - public EventHeaderTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public EventHeaderTrait(ObjectNode node) { + super(ID, node); } public EventHeaderTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/EventPayloadTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/EventPayloadTrait.java index 5363dfb3279..496404f00eb 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/EventPayloadTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/EventPayloadTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -27,12 +28,12 @@ public final class EventPayloadTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#eventPayload"); - public EventPayloadTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public EventPayloadTrait(ObjectNode node) { + super(ID, node); } public EventPayloadTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HostLabelTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HostLabelTrait.java index cad9d16a72b..c4c6a174495 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HostLabelTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HostLabelTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -25,12 +26,12 @@ public final class HostLabelTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#hostLabel"); - public HostLabelTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public HostLabelTrait(ObjectNode node) { + super(ID, node); } public HostLabelTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpBasicAuthTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpBasicAuthTrait.java index 8e06ea8563c..8a5c4c5f9dc 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpBasicAuthTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpBasicAuthTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -26,11 +27,11 @@ public final class HttpBasicAuthTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#httpBasicAuth"); public HttpBasicAuthTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } - public HttpBasicAuthTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public HttpBasicAuthTrait(ObjectNode node) { + super(ID, node); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpBearerAuthTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpBearerAuthTrait.java index 0a8c47240ed..e642e12bf83 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpBearerAuthTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpBearerAuthTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -26,11 +27,11 @@ public final class HttpBearerAuthTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#httpBearerAuth"); public HttpBearerAuthTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } - public HttpBearerAuthTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public HttpBearerAuthTrait(ObjectNode node) { + super(ID, node); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpDigestAuthTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpDigestAuthTrait.java index 3309c0a4366..7898343dd6d 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpDigestAuthTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpDigestAuthTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -26,11 +27,11 @@ public final class HttpDigestAuthTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#httpDigestAuth"); public HttpDigestAuthTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } - public HttpDigestAuthTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public HttpDigestAuthTrait(ObjectNode node) { + super(ID, node); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpLabelTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpLabelTrait.java index 23608d3d9a8..07790892b62 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpLabelTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpLabelTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -25,12 +26,12 @@ public final class HttpLabelTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#httpLabel"); - public HttpLabelTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public HttpLabelTrait(ObjectNode node) { + super(ID, node); } public HttpLabelTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpPayloadTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpPayloadTrait.java index c30b495b98d..e7cbb108bcb 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpPayloadTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/HttpPayloadTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -24,12 +25,12 @@ public final class HttpPayloadTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#httpPayload"); - public HttpPayloadTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public HttpPayloadTrait(ObjectNode node) { + super(ID, node); } public HttpPayloadTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/IdempotencyTokenTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/IdempotencyTokenTrait.java index 646ace190b7..8e552e2b296 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/IdempotencyTokenTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/IdempotencyTokenTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -25,12 +26,12 @@ public final class IdempotencyTokenTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#idempotencyToken"); - public IdempotencyTokenTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public IdempotencyTokenTrait(ObjectNode node) { + super(ID, node); } public IdempotencyTokenTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/IdempotentTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/IdempotentTrait.java index 6eab341b31b..88ca3cb1964 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/IdempotentTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/IdempotentTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -24,12 +25,12 @@ public final class IdempotentTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#idempotent"); - public IdempotentTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public IdempotentTrait(ObjectNode node) { + super(ID, node); } public IdempotentTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/NoReplaceTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/NoReplaceTrait.java index c96d8231021..61a6d98baaa 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/NoReplaceTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/NoReplaceTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -26,12 +27,12 @@ public final class NoReplaceTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#noReplace"); - public NoReplaceTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public NoReplaceTrait(ObjectNode node) { + super(ID, node); } public NoReplaceTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/OptionalAuthTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/OptionalAuthTrait.java index 43ec144dda5..2b941303f6a 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/OptionalAuthTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/OptionalAuthTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -25,11 +26,11 @@ public final class OptionalAuthTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#optionalAuth"); public OptionalAuthTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } - public OptionalAuthTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public OptionalAuthTrait(ObjectNode node) { + super(ID, node); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/PrivateTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/PrivateTrait.java index 70ad7019936..6a6db1f67c8 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/PrivateTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/PrivateTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -25,12 +26,12 @@ public final class PrivateTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#private"); - public PrivateTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public PrivateTrait(ObjectNode node) { + super(ID, node); } public PrivateTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/ReadonlyTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/ReadonlyTrait.java index 46484aff06b..0cd935ee450 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/ReadonlyTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/ReadonlyTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -24,12 +25,12 @@ public final class ReadonlyTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#readonly"); - public ReadonlyTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public ReadonlyTrait(ObjectNode node) { + super(ID, node); } public ReadonlyTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/RequiredTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/RequiredTrait.java index d0e3bd8f6ac..b44059d6ce5 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/RequiredTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/RequiredTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -24,12 +25,12 @@ public final class RequiredTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#required"); - public RequiredTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public RequiredTrait(ObjectNode node) { + super(ID, node); } public RequiredTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/RequiresLengthTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/RequiresLengthTrait.java index 44622627ce4..8d291390494 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/RequiresLengthTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/RequiresLengthTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -24,12 +25,12 @@ public final class RequiresLengthTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#requiresLength"); - public RequiresLengthTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public RequiresLengthTrait(ObjectNode node) { + super(ID, node); } public RequiresLengthTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/SensitiveTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/SensitiveTrait.java index d84adfd647c..e16e78cd0bf 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/SensitiveTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/SensitiveTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -25,12 +26,12 @@ public final class SensitiveTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#sensitive"); - public SensitiveTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public SensitiveTrait(ObjectNode node) { + super(ID, node); } public SensitiveTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/StreamingTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/StreamingTrait.java index e8a4090da53..d5079368a15 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/StreamingTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/StreamingTrait.java @@ -16,7 +16,8 @@ package software.amazon.smithy.model.traits; import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.MemberShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.ShapeId; @@ -29,12 +30,12 @@ public final class StreamingTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#streaming"); - public StreamingTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public StreamingTrait(ObjectNode node) { + super(ID, node); } public StreamingTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/UniqueItemsTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/UniqueItemsTrait.java index 920449dd8d9..68be5d9560b 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/UniqueItemsTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/UniqueItemsTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -24,12 +25,12 @@ public final class UniqueItemsTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#uniqueItems"); - public UniqueItemsTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public UniqueItemsTrait(ObjectNode node) { + super(ID, node); } public UniqueItemsTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/UnstableTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/UnstableTrait.java index db9ec9212f6..aeacc43fb38 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/UnstableTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/UnstableTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -24,12 +25,12 @@ public final class UnstableTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#unstable"); - public UnstableTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public UnstableTrait(ObjectNode node) { + super(ID, node); } public UnstableTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/XmlAttributeTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/XmlAttributeTrait.java index bae298e793d..d11db7b9c79 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/XmlAttributeTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/XmlAttributeTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; /** @@ -24,12 +25,12 @@ public final class XmlAttributeTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#xmlAttribute"); - public XmlAttributeTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public XmlAttributeTrait(ObjectNode node) { + super(ID, node); } public XmlAttributeTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/traits/XmlFlattenedTrait.java b/smithy-model/src/main/java/software/amazon/smithy/model/traits/XmlFlattenedTrait.java index 694c64b630a..9cb5788fdb2 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/traits/XmlFlattenedTrait.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/traits/XmlFlattenedTrait.java @@ -15,18 +15,19 @@ package software.amazon.smithy.model.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; public class XmlFlattenedTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.api#xmlFlattened"); - public XmlFlattenedTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public XmlFlattenedTrait(ObjectNode node) { + super(ID, node); } public XmlFlattenedTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/validation/NodeValidationVisitor.java b/smithy-model/src/main/java/software/amazon/smithy/model/validation/NodeValidationVisitor.java index 7a1ac5ad6f1..10084df22be 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/validation/NodeValidationVisitor.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/validation/NodeValidationVisitor.java @@ -274,7 +274,7 @@ public List structureShape(StructureShape shape) { String key = keyNode.getValue(); if (!members.containsKey(key)) { events.add(event("Invalid structure member `" + key + "` found for `" - + shape.getId() + "`")); + + shape.getId() + "`", Severity.WARNING)); } else { events.addAll(withNode(key, value).memberShape(members.get(key))); } @@ -369,9 +369,13 @@ private List invalidSchema(Shape shape) { } private ValidationEvent event(String message) { + return event(message, Severity.ERROR); + } + + private ValidationEvent event(String message, Severity severity) { return ValidationEvent.builder() .eventId(eventId) - .severity(Severity.ERROR) + .severity(severity) .sourceLocation(value.getSourceLocation()) .shapeId(eventShapeId) .message(context.isEmpty() ? message : context + ": " + message) diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/HttpBindingIndexTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/HttpBindingIndexTest.java index 3c98b91429c..61aaae4c6b9 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/HttpBindingIndexTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/HttpBindingIndexTest.java @@ -148,7 +148,7 @@ public void returnsResponseMemberBindingsWithExplicitBody() { expectMember(model, "ns.foo#ServiceOperationExplicitBodyOutput$baz"), HttpBinding.Location.PAYLOAD, "baz", - new HttpPayloadTrait(SourceLocation.NONE)))); + new HttpPayloadTrait()))); } @Test @@ -188,7 +188,7 @@ public void findsUnboundMembers() { .addMember(MemberShape.builder() .id("ns.foo#Input$bar") .target("ns.foo#String") - .addTrait(new HttpPayloadTrait(SourceLocation.NONE)) + .addTrait(new HttpPayloadTrait()) .build()) .addMember(MemberShape.builder().id("ns.foo#Input$baz").target("ns.foo#String").build()) .build(); @@ -213,7 +213,7 @@ public void checksForHttpRequestAndResponseBindings() { Shape shape = MemberShape.builder() .target("smithy.api#Timestamp") .id("smithy.example#Baz$bar") - .addTrait(new HttpLabelTrait(SourceLocation.NONE)) + .addTrait(new HttpLabelTrait()) .build(); assertThat(HttpBindingIndex.hasHttpRequestBindings(shape), is(true)); diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/IdentifierBindingIndexTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/IdentifierBindingIndexTest.java index a28f9284241..37e77725064 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/IdentifierBindingIndexTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/knowledge/IdentifierBindingIndexTest.java @@ -54,7 +54,7 @@ public void findsImplicitInstanceBindings() { .id("ns.foo#Input") .addMember(MemberShape.builder() .id("ns.foo#Input$abc") - .addTrait(new RequiredTrait(SourceLocation.NONE)) + .addTrait(new RequiredTrait()) .target("ns.foo#Id").build()) .build(); OperationShape operation = OperationShape.builder().id("ns.foo#Operation").input(input.getId()).build(); @@ -125,7 +125,7 @@ public void findsExplicitBindings() { .id("ns.foo#Input") .addMember(MemberShape.builder() .id("ns.foo#Input$def") - .addTrait(new RequiredTrait(SourceLocation.NONE)) + .addTrait(new RequiredTrait()) .addTrait(new ResourceIdentifierTrait("abc", SourceLocation.NONE)) .target("smithy.api#String").build()) .build(); diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/BottomUpNeighborVisitorTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/BottomUpNeighborVisitorTest.java index fdab225fd50..df68acaa00f 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/BottomUpNeighborVisitorTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/BottomUpNeighborVisitorTest.java @@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test; import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.shapes.BlobShape; import software.amazon.smithy.model.shapes.ListShape; import software.amazon.smithy.model.shapes.MapShape; @@ -252,16 +251,16 @@ public void operationShape() { OperationShape createOperation = OperationShape.builder().id("ns.foo#Create").build(); OperationShape getOperation = OperationShape.builder() .id("ns.foo#Get") - .addTrait(new ReadonlyTrait(SourceLocation.NONE)) + .addTrait(new ReadonlyTrait()) .build(); OperationShape updateOperation = OperationShape.builder().id("ns.foo#Update").build(); OperationShape deleteOperation = OperationShape.builder() .id("ns.foo#Delete") - .addTrait(new IdempotentTrait(SourceLocation.NONE)) + .addTrait(new IdempotentTrait()) .build(); OperationShape listOperation = OperationShape.builder() .id("ns.foo#List") - .addTrait(new ReadonlyTrait(SourceLocation.NONE)) + .addTrait(new ReadonlyTrait()) .build(); OperationShape namedOperation = OperationShape.builder() .id("ns.foo#Named") diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/NeighborVisitorTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/NeighborVisitorTest.java index 97d57914f58..2865d2c04cd 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/NeighborVisitorTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/NeighborVisitorTest.java @@ -23,7 +23,6 @@ import java.util.List; import org.junit.jupiter.api.Test; import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.shapes.BlobShape; import software.amazon.smithy.model.shapes.BooleanShape; import software.amazon.smithy.model.shapes.ListShape; @@ -235,16 +234,16 @@ public void resourceShape() { OperationShape createOperation = OperationShape.builder().id("ns.foo#Create").build(); OperationShape getOperation = OperationShape.builder() .id("ns.foo#Get") - .addTrait(new ReadonlyTrait(SourceLocation.NONE)) + .addTrait(new ReadonlyTrait()) .build(); OperationShape updateOperation = OperationShape.builder().id("ns.foo#Update").build(); OperationShape deleteOperation = OperationShape.builder() .id("ns.foo#Delete") - .addTrait(new IdempotentTrait(SourceLocation.NONE)) + .addTrait(new IdempotentTrait()) .build(); OperationShape listOperation = OperationShape.builder() .id("ns.foo#List") - .addTrait(new ReadonlyTrait(SourceLocation.NONE)) + .addTrait(new ReadonlyTrait()) .build(); OperationShape namedOperation = OperationShape.builder() .id("ns.foo#Named") diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/UnreferencedShapesTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/UnreferencedShapesTest.java index 3b72266099a..41e4d75897f 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/UnreferencedShapesTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/neighbor/UnreferencedShapesTest.java @@ -26,7 +26,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.shapes.StringShape; @@ -77,7 +76,7 @@ public void doesNotIgnorePrivateShapes() { private Model createPrivateShapeModel(ShapeId id) { return Model.assembler() - .addShape(StringShape.builder().id(id).addTrait(new PrivateTrait(SourceLocation.NONE)).build()) + .addShape(StringShape.builder().id(id).addTrait(new PrivateTrait()).build()) .assemble() .unwrap(); } diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/selector/AndSelectorTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/selector/AndSelectorTest.java index e51b49a314c..97602643722 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/selector/AndSelectorTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/selector/AndSelectorTest.java @@ -23,7 +23,6 @@ import java.util.Set; import org.junit.jupiter.api.Test; import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.shapes.IntegerShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.ShapeType; @@ -37,7 +36,7 @@ public void matchesAllPredicates() { new ShapeTypeSelector(ShapeType.STRING), new AttributeSelector(new TraitAttributeKey("sensitive")))); Shape a = IntegerShape.builder().id("foo.baz#Bar").build(); - Shape b = StringShape.builder().id("foo.baz#Bam").addTrait(new SensitiveTrait(SourceLocation.NONE)).build(); + Shape b = StringShape.builder().id("foo.baz#Bam").addTrait(new SensitiveTrait()).build(); Model model = Model.builder().addShapes(a, b).build(); Set result = selector.select(model); @@ -50,7 +49,7 @@ public void shortCircuits() { new ShapeTypeSelector(ShapeType.BIG_INTEGER), new AttributeSelector(new TraitAttributeKey("sensitive")))); Shape a = IntegerShape.builder().id("foo.baz#Bar").build(); - Shape b = StringShape.builder().id("foo.baz#Bam").addTrait(new SensitiveTrait(SourceLocation.NONE)).build(); + Shape b = StringShape.builder().id("foo.baz#Bam").addTrait(new SensitiveTrait()).build(); Model model = Model.builder().addShapes(a, b).build(); Set result = selector.select(model); diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/selector/OfSelectorTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/selector/OfSelectorTest.java index 931aa7802de..3a301bdc8df 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/selector/OfSelectorTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/selector/OfSelectorTest.java @@ -25,7 +25,6 @@ import java.util.Set; import org.junit.jupiter.api.Test; import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.shapes.ListShape; import software.amazon.smithy.model.shapes.MemberShape; import software.amazon.smithy.model.shapes.Shape; @@ -71,7 +70,7 @@ private Model createModel() { .build(); Shape b = StructureShape.builder().id("foo.baz#B") .addMember(bMember) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); MemberShape cMember = MemberShape.builder() .id("foo.baz#C$member") diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/shapes/ModelSerializerTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/shapes/ModelSerializerTest.java index 53463757a46..d4e65e8582c 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/shapes/ModelSerializerTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/shapes/ModelSerializerTest.java @@ -91,7 +91,7 @@ public void filtersShapes() { public void canFilterTraits() { Shape shape = StringShape.builder() .id("ns.foo#baz") - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .addTrait(new DocumentationTrait("docs", SourceLocation.NONE)) .build(); Model model = Model.assembler().addShape(shape).assemble().unwrap(); diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/traits/AnnotationTraitTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/traits/AnnotationTraitTest.java index f16cd88fab3..7d92ff7e6b1 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/traits/AnnotationTraitTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/traits/AnnotationTraitTest.java @@ -9,8 +9,10 @@ import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.node.ArrayNode; import software.amazon.smithy.model.node.ExpectationNotMetException; +import software.amazon.smithy.model.node.Node; import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.utils.MapUtils; public class AnnotationTraitTest { @Test @@ -31,4 +33,14 @@ public void validatesAnnotationTraits() { new SensitiveTrait.Provider().createTrait(ShapeId.from("foo#bar"), arrayNode); }); } + + @Test + public void annotationTraitsAreNotLossy() { + ObjectNode objectNode = new ObjectNode( + MapUtils.of(Node.from("hi"), Node.from("bye")), + SourceLocation.NONE); + SensitiveTrait trait = new SensitiveTrait.Provider().createTrait(ShapeId.from("foo#bar"), objectNode); + + assertThat(trait.toNode(), equalTo(objectNode)); + } } diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/transform/FilterShapesTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/transform/FilterShapesTest.java index 7fb7af604a2..f491111a08b 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/transform/FilterShapesTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/transform/FilterShapesTest.java @@ -22,7 +22,6 @@ import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.node.Node; import software.amazon.smithy.model.shapes.ListShape; import software.amazon.smithy.model.shapes.MapShape; @@ -42,7 +41,7 @@ public void removesShapesThatMatchPredicate() { ShapeId aId = ShapeId.from("ns.foo#A"); StringShape a = StringShape.builder() .id(aId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); ShapeId bId = ShapeId.from("ns.foo#B"); StringShape b = StringShape.builder().id(bId).build(); @@ -128,14 +127,14 @@ public void removesTraitsWhenDefinitionIsRemoved() { StringShape shape1 = StringShape.builder() .id(shapeId1) .addTrait(new DynamicTrait(ShapeId.from("foo.baz#foo"), Node.from(true))) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); ShapeId shapeId2 = ShapeId.from("ns.foo#id2"); StringShape shape2 = StringShape.builder() .id(shapeId2) .addTrait(new DynamicTrait(ShapeId.from("ns.foo#baz"), Node.from(true))) .addTrait(new DynamicTrait(ShapeId.from("ns.foo#bar"), Node.from(true))) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model model = Model.builder() .addShapes(shape1, shape2, bazTrait, barTrait) diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/transform/FilterTraitsTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/transform/FilterTraitsTest.java index 6ef589613bc..46395485e77 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/transform/FilterTraitsTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/transform/FilterTraitsTest.java @@ -35,13 +35,13 @@ public void removesTraits() { ShapeId aId = ShapeId.from("ns.foo#A"); StringShape a = StringShape.builder() .id(aId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .addTrait(DeprecatedTrait.builder().build()) .build(); ShapeId bId = ShapeId.from("ns.foo#B"); StringShape b = StringShape.builder() .id(bId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .addTrait(DeprecatedTrait.builder().build()) .build(); Model model = Model.builder().addShapes(a, b).build(); @@ -61,7 +61,7 @@ public void removesTraitsWithComposedPredicate() { ShapeId aId = ShapeId.from("ns.foo#A"); StringShape a = StringShape.builder() .id(aId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .addTrait(new DocumentationTrait("docs", SourceLocation.NONE)) .addTrait(DeprecatedTrait.builder().build()) .build(); diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/transform/MapShapesTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MapShapesTest.java index b91ba80a9f7..043cf7890ed 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/transform/MapShapesTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MapShapesTest.java @@ -37,7 +37,7 @@ public void replacesMappedShapes() { ShapeId shapeId = ShapeId.from("ns.foo#id1"); StringShape shape = StringShape.builder() .id(shapeId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model model = Model.builder().addShape(shape).build(); ModelTransformer transformer = ModelTransformer.create(); @@ -63,7 +63,7 @@ public void mapsUsingAllMappers() { ShapeId shapeId = ShapeId.from("ns.foo#id1"); StringShape shape = StringShape.builder() .id(shapeId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .addTrait(new DocumentationTrait("docs", SourceLocation.NONE)) .build(); Model model = Model.builder().addShape(shape).build(); diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/transform/MapTraitsTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MapTraitsTest.java index a6f744782f4..292927530fb 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/transform/MapTraitsTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/transform/MapTraitsTest.java @@ -36,7 +36,7 @@ public void doesNotReplaceUnchangedShapes() { ShapeId shapeId = ShapeId.from("ns.foo#id1"); StringShape shape = StringShape.builder() .id(shapeId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model model = Model.builder().addShape(shape).build(); ModelTransformer transformer = ModelTransformer.create(); diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/transform/RemoveShapesTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/transform/RemoveShapesTest.java index 791e0e12c08..8fc46e1a51d 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/transform/RemoveShapesTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/transform/RemoveShapesTest.java @@ -24,7 +24,6 @@ import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.shapes.ListShape; import software.amazon.smithy.model.shapes.MapShape; import software.amazon.smithy.model.shapes.MemberShape; @@ -125,7 +124,7 @@ public void removesOperationsFromResourcesWhenOperationRemoved() { .build(); OperationShape a = OperationShape.builder() .id("ns.foo#A") - .addTrait(new ReadonlyTrait(SourceLocation.NONE)) + .addTrait(new ReadonlyTrait()) .build(); OperationShape b = OperationShape.builder().id("ns.foo#B").build(); OperationShape c = OperationShape.builder().id("ns.foo#C").build(); diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/transform/ReplaceShapesTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/transform/ReplaceShapesTest.java index aace51dae4c..0e93e46f344 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/transform/ReplaceShapesTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/transform/ReplaceShapesTest.java @@ -66,7 +66,7 @@ public void updatesListMemberWhenContainerUpdated() { MemberShape newMember = MemberShape.builder() .id(memberId) .target(stringId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); ListShape newList = ListShape.builder().id(containerId).member(newMember).build(); Model result = transformer.replaceShapes(model, Arrays.asList(newList)); @@ -96,12 +96,12 @@ public void updatesMapMembersWhenContainerUpdated() { MemberShape newKey = MemberShape.builder() .id(keyId) .target(stringId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); MemberShape newValue = MemberShape.builder() .id(valueId) .target(stringId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); MapShape newMap = MapShape.builder().id(containerId).key(newKey).value(newValue).build(); Model result = transformer.replaceShapes(model, Arrays.asList(newMap)); @@ -129,7 +129,7 @@ public void updatesTaggedUnionMembersWhenContainerUpdated() { // Add a trait to a replaced member3. MemberShape newMember3 = MemberShape.builder() .id("ns.foo#Shape$member3") - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .target("ns.foo#String") .build(); // Replace the union with a shape that has the new member3. @@ -160,7 +160,7 @@ public void updatesListShapeWhenMemberModified() { MemberShape newMember = MemberShape.builder() .id(memberId) .target(stringId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model result = transformer.replaceShapes(model, Arrays.asList(newMember)); @@ -185,13 +185,13 @@ public void updatesMapShapeWhenKeyOrValueIsUpdated() { MemberShape newKeyMember = MemberShape.builder() .id(keyMemberId) .target(stringId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model resultWithNewKey = transformer.replaceShapes(model, Arrays.asList(newKeyMember)); MemberShape newValueMember = MemberShape.builder() .id(valueMemberId) .target(stringId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model resultWithNewValue = transformer.replaceShapes(model, Arrays.asList(newValueMember)); @@ -216,7 +216,7 @@ public void updatesStructureWhenMemberChanges() { MemberShape memberA = MemberShape.builder() .id(memberAId) .target(stringId) - .addTrait(new RequiredTrait(SourceLocation.NONE)) + .addTrait(new RequiredTrait()) .build(); MemberShape memberB = MemberShape.builder().id(memberBId).target(stringId).build(); StructureShape container = StructureShape.builder() @@ -231,7 +231,7 @@ public void updatesStructureWhenMemberChanges() { MemberShape newMemberB = MemberShape.builder() .id(memberBId) .target(stringId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model result = transformer.replaceShapes(model, Arrays.asList(newMemberB)); @@ -262,8 +262,8 @@ public void canReplaceMultipleMembersOfSameShape() { .addShapes(target, memberA, memberB, container) .build(); ModelTransformer transformer = ModelTransformer.create(); - MemberShape newMemberA = memberA.toBuilder().addTrait(new RequiredTrait(SourceLocation.NONE)).build(); - MemberShape newMemberB = memberB.toBuilder().addTrait(new RequiredTrait(SourceLocation.NONE)).build(); + MemberShape newMemberA = memberA.toBuilder().addTrait(new RequiredTrait()).build(); + MemberShape newMemberB = memberB.toBuilder().addTrait(new RequiredTrait()).build(); Model result = transformer.replaceShapes(model, Arrays.asList(newMemberA, newMemberB)); assertThat(result.getShape(memberAId).get().getTrait(RequiredTrait.class), Matchers.not(Optional.empty())); @@ -301,7 +301,7 @@ public void updatesTaggedUnionShapeWhenMemberChanges() { MemberShape newMemberB = MemberShape.builder() .id(memberBId) .target(stringId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model result = transformer.replaceShapes(model, Arrays.asList(newMemberB)); @@ -334,7 +334,7 @@ public void doesNotOverwriteOtherContainerUpdatesWhenAlsoUpdatingMembers() { MemberShape newMember = MemberShape.builder() .id(memberId) .target(stringId) - .addTrait(new SensitiveTrait(SourceLocation.NONE)) + .addTrait(new SensitiveTrait()) .build(); Model result = transformer.replaceShapes(model, Arrays.asList(newMember, newContainer)); diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/annotation-trait-extra-properties.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/annotation-trait-extra-properties.errors new file mode 100644 index 00000000000..3c01e7d2fdf --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/annotation-trait-extra-properties.errors @@ -0,0 +1 @@ +[WARNING] ns.foo#Baz: Error validating trait `sensitive`: Invalid structure member `test` found for `smithy.api#sensitive` | TraitValue diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/annotation-trait-extra-properties.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/annotation-trait-extra-properties.json new file mode 100644 index 00000000000..5a3ee49e2a3 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/annotation-trait-extra-properties.json @@ -0,0 +1,13 @@ +{ + "smithy": "1.0.0", + "shapes": { + "ns.foo#Baz": { + "type": "string", + "traits": { + "smithy.api#sensitive": { + "test": 123 + } + } + } + } +} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/examples-trait-validator.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/examples-trait-validator.errors index 840b077e9b7..0be6d518cf5 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/examples-trait-validator.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/examples-trait-validator.errors @@ -1,5 +1,5 @@ [ERROR] ns.foo#Operation2: Input parameters provided for operation with no input structure members: `Testing 3` | ExamplesTrait [ERROR] ns.foo#Operation2: Output parameters provided for operation with no output structure members: `Testing 3` | ExamplesTrait [ERROR] ns.foo#Operation: Example input of `Testing 2`: Missing required structure member `foo` for `ns.foo#OperationInput` | ExamplesTrait -[ERROR] ns.foo#Operation: Example output of `Testing 2`: Invalid structure member `additional` found for `ns.foo#OperationOutput` | ExamplesTrait +[WARNING] ns.foo#Operation: Example output of `Testing 2`: Invalid structure member `additional` found for `ns.foo#OperationOutput` | ExamplesTrait [ERROR] ns.foo#Operation: Example output of `Testing 2`: Missing required structure member `bam` for `ns.foo#OperationOutput` | ExamplesTrait diff --git a/smithy-mqtt-traits/src/main/java/software/amazon/smithy/mqtt/traits/MqttJsonTrait.java b/smithy-mqtt-traits/src/main/java/software/amazon/smithy/mqtt/traits/MqttJsonTrait.java index 0b10dc05f7e..b02f790c443 100644 --- a/smithy-mqtt-traits/src/main/java/software/amazon/smithy/mqtt/traits/MqttJsonTrait.java +++ b/smithy-mqtt-traits/src/main/java/software/amazon/smithy/mqtt/traits/MqttJsonTrait.java @@ -15,19 +15,20 @@ package software.amazon.smithy.mqtt.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.AnnotationTrait; public final class MqttJsonTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.mqtt#mqttJson"); - public MqttJsonTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public MqttJsonTrait(ObjectNode node) { + super(ID, node); } public MqttJsonTrait() { - this(SourceLocation.NONE); + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-mqtt-traits/src/main/java/software/amazon/smithy/mqtt/traits/TopicLabelTrait.java b/smithy-mqtt-traits/src/main/java/software/amazon/smithy/mqtt/traits/TopicLabelTrait.java index f2246beca89..eca9651ac12 100644 --- a/smithy-mqtt-traits/src/main/java/software/amazon/smithy/mqtt/traits/TopicLabelTrait.java +++ b/smithy-mqtt-traits/src/main/java/software/amazon/smithy/mqtt/traits/TopicLabelTrait.java @@ -15,7 +15,8 @@ package software.amazon.smithy.mqtt.traits; -import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.AnnotationTrait; @@ -25,8 +26,12 @@ public final class TopicLabelTrait extends AnnotationTrait { public static final ShapeId ID = ShapeId.from("smithy.mqtt#topicLabel"); - public TopicLabelTrait(SourceLocation sourceLocation) { - super(ID, sourceLocation); + public TopicLabelTrait(ObjectNode node) { + super(ID, node); + } + + public TopicLabelTrait() { + this(Node.objectNode()); } public static final class Provider extends AnnotationTrait.Provider { diff --git a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-invalid-params.errors b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-invalid-params.errors index 9803bcaa34d..fddc284bfdf 100644 --- a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-invalid-params.errors +++ b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-invalid-params.errors @@ -1,3 +1,3 @@ [ERROR] smithy.example#MyError: smithy.test#httpResponseTests.0.params.foo: Expected number value for integer shape, `smithy.api#Integer`; found string value, `Hi` | HttpResponseTestsError -[ERROR] smithy.example#SayGoodbye: smithy.test#httpResponseTests.0.params: Invalid structure member `invalid` found for `smithy.example#SayGoodbyeOutput` | HttpResponseTestsOutput +[WARNING] smithy.example#SayGoodbye: smithy.test#httpResponseTests.0.params: Invalid structure member `invalid` found for `smithy.example#SayGoodbyeOutput` | HttpResponseTestsOutput [ERROR] smithy.example#SayHello: smithy.test#httpRequestTests.0.params.badType: Expected boolean value for boolean shape, `smithy.api#Boolean`; found string value, `hi` | HttpRequestTestsInput