diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/Ordering.cs b/src/LEGO.AsyncAPI.Bindings/Sns/Ordering.cs index 4ed81eec..f80c953b 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/Ordering.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/Ordering.cs @@ -12,14 +12,14 @@ public class Ordering : IAsyncApiExtensible /// What type of SNS Topic is this? /// public OrderingType Type { get; set; } - + /// /// True to turn on de-duplication of messages for a channel. /// public bool ContentBasedDeduplication { get; set; } public IDictionary Extensions { get; set; } = new Dictionary(); - + public void Serialize(IAsyncApiWriter writer) { if (writer is null) diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/SnsChannelBinding.cs b/src/LEGO.AsyncAPI.Bindings/Sns/SnsChannelBinding.cs index 913b512b..65043449 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/SnsChannelBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/SnsChannelBinding.cs @@ -36,7 +36,6 @@ public class SnsChannelBinding : ChannelBinding protected override FixedFieldMap FixedFieldMap => new() { { "name", (a, n) => { a.Name = n.GetScalarValue(); } }, - { "type", (a, n) => { a.Ordering = n.ParseMapWithExtensions(this.orderingFixedFields); } }, { "ordering", (a, n) => { a.Ordering = n.ParseMapWithExtensions(this.orderingFixedFields); } }, { "policy", (a, n) => { a.Policy = n.ParseMapWithExtensions(this.policyFixedFields); } }, { "tags", (a, n) => { a.Tags = n.CreateSimpleMap(s => s.GetScalarValue()); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/StringOrStringList.cs b/src/LEGO.AsyncAPI.Bindings/StringOrStringList.cs index 4653d586..c2f323cc 100644 --- a/src/LEGO.AsyncAPI.Bindings/StringOrStringList.cs +++ b/src/LEGO.AsyncAPI.Bindings/StringOrStringList.cs @@ -14,7 +14,7 @@ public class StringOrStringList : IAsyncApiElement { public StringOrStringList(AsyncApiAny value) { - this.Value = value.Node switch + this.Value = value.GetNode() switch { JsonArray array => IsValidStringList(array) ? new AsyncApiAny(array) : throw new ArgumentException($"{nameof(StringOrStringList)} value should only contain string items."), JsonValue jValue => IsString(jValue) ? new AsyncApiAny(jValue) : throw new ArgumentException($"{nameof(StringOrStringList)} should be a string value or a string list."), diff --git a/src/LEGO.AsyncAPI/Models/Any/AsyncAPIArray.cs b/src/LEGO.AsyncAPI/Models/Any/AsyncAPIArray.cs index ec62159a..042b1f68 100644 --- a/src/LEGO.AsyncAPI/Models/Any/AsyncAPIArray.cs +++ b/src/LEGO.AsyncAPI/Models/Any/AsyncAPIArray.cs @@ -13,7 +13,7 @@ public class AsyncApiArray : Collection, IAsyncApiExtension, IAsync public static explicit operator AsyncApiArray(AsyncApiAny any) { var a = new AsyncApiArray(); - if (any.Node is JsonArray arr) + if (any.GetNode() is JsonArray arr) { foreach (var item in arr) { @@ -29,7 +29,7 @@ public static implicit operator AsyncApiAny(AsyncApiArray arr) var jArray = new JsonArray(); foreach (var item in arr) { - jArray.Add(item.Node); + jArray.Add(item.GetNode()); } return new AsyncApiAny(jArray); diff --git a/src/LEGO.AsyncAPI/Models/Any/AsyncAPIObject.cs b/src/LEGO.AsyncAPI/Models/Any/AsyncAPIObject.cs index f620a4f2..90e8e124 100644 --- a/src/LEGO.AsyncAPI/Models/Any/AsyncAPIObject.cs +++ b/src/LEGO.AsyncAPI/Models/Any/AsyncAPIObject.cs @@ -18,7 +18,7 @@ public static implicit operator AsyncApiAny(AsyncApiObject obj) var jObject = new JsonObject(); foreach (var item in obj) { - jObject.Add(item.Key, item.Value.Node); + jObject.Add(item.Key, item.Value.GetNode()); } return new AsyncApiAny(jObject); diff --git a/src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs b/src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs index 3b866cd6..098c88d4 100644 --- a/src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs +++ b/src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs @@ -30,7 +30,7 @@ public AsyncApiAny(JsonNode node) /// /// The node. /// - public JsonNode Node => this.node; + public JsonNode GetNode() => this.node; public T GetValue() { diff --git a/src/LEGO.AsyncAPI/Writers/AsyncApiWriterAnyExtensions.cs b/src/LEGO.AsyncAPI/Writers/AsyncApiWriterAnyExtensions.cs index 201ce127..fe2a34a1 100644 --- a/src/LEGO.AsyncAPI/Writers/AsyncApiWriterAnyExtensions.cs +++ b/src/LEGO.AsyncAPI/Writers/AsyncApiWriterAnyExtensions.cs @@ -54,13 +54,13 @@ public static void WriteAny(this IAsyncApiWriter writer, AsyncApiAny any) throw new ArgumentNullException(nameof(writer)); } - if (any.Node == null) + if (any.GetNode() == null) { writer.WriteNull(); return; } - var node = any.Node; + var node = any.GetNode(); var element = JsonDocument.Parse(node.ToJsonString()).RootElement; switch (element.ValueKind) diff --git a/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs b/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs index 33a593f0..1214da3c 100644 --- a/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs +++ b/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs @@ -40,7 +40,7 @@ public void Read_WithExtensionParser_Parses() "; Func valueExtensionParser = (any) => { - if (any.Node is JsonValue value) + if (any.GetNode() is JsonValue value) { if (value.GetScalarValue() == "onetwothreefour") { diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/Sns/SnsBindings_Should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/Sns/SnsBindings_Should.cs index 9642d141..d4d5cf05 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/Sns/SnsBindings_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/Sns/SnsBindings_Should.cs @@ -141,11 +141,11 @@ public void SnsChannelBinding_WithFilledObject_SerializesAndDeserializes() // Assert Assert.AreEqual(actual, expected); - + var expectedSnsBinding = (SnsChannelBinding)channel.Bindings.Values.First(); - expectedSnsBinding.Should().BeEquivalentTo((SnsChannelBinding)binding.Bindings.Values.First()); + expectedSnsBinding.Should().BeEquivalentTo((SnsChannelBinding)binding.Bindings.Values.First(), options => options.IgnoringCyclicReferences()); } - + [Test] public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() { @@ -382,12 +382,11 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() settings.Bindings = BindingsCollection.Sns; var binding = new AsyncApiStringReader(settings).ReadFragment(actual, AsyncApiVersion.AsyncApi2_0, out _); - // Assert Assert.AreEqual(actual, expected); - + var expectedSnsBinding = (SnsOperationBinding)operation.Bindings.Values.First(); - expectedSnsBinding.Should().BeEquivalentTo((SnsOperationBinding)binding.Bindings.Values.First()); + expectedSnsBinding.Should().BeEquivalentTo((SnsOperationBinding)binding.Bindings.Values.First(), options => options.IgnoringCyclicReferences()); } } } \ No newline at end of file diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs index cc4b7aa7..0849aa85 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs @@ -398,11 +398,7 @@ public void AsyncApiMessage_WithFilledObject_Serializes() // Assert Assert.AreEqual(expected, actual); - message.Should().BeEquivalentTo(deserializedMessage, options => options.IgnoringCyclicReferences() - .Excluding(message => message.Headers.Examples[0].Node.Parent) - .Excluding(message => message.Traits[0].Headers.Examples[0].Node.Parent) - .Excluding(message => message.Traits[0].Examples[0].Payload.Node.Parent) - .Excluding(message => message.Examples[0].Payload.Node.Parent)); + message.Should().BeEquivalentTo(deserializedMessage); } } } diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs index 9041d0b8..686ed9b6 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs @@ -605,10 +605,7 @@ public void Deserialize_WithAdvancedSchema_Works() var actual = new AsyncApiStringReader().ReadFragment(json, AsyncApiVersion.AsyncApi2_0, out var _diagnostics); // Assert - actual.Should().BeEquivalentTo(expected, options => options.IgnoringCyclicReferences() - .Excluding(actual => actual.Properties["property11"].Const.Node.Parent) - .Excluding(actual => actual.Properties["property11"].Const.Node.Root)); - _diagnostics.Errors.Should().BeEmpty(); + actual.Should().BeEquivalentTo(expected); } [Test]