diff --git a/src/LEGO.AsyncAPI.Bindings/AMQP/AMQPChannelBinding.cs b/src/LEGO.AsyncAPI.Bindings/AMQP/AMQPChannelBinding.cs index f77dc37f..ebfed688 100644 --- a/src/LEGO.AsyncAPI.Bindings/AMQP/AMQPChannelBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/AMQP/AMQPChannelBinding.cs @@ -29,7 +29,7 @@ public class AMQPChannelBinding : ChannelBinding public override string BindingKey => "amqp"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "is", (a, n) => { a.Is = n.GetScalarValue().GetEnumFromDisplayName(); } }, @@ -37,7 +37,7 @@ public class AMQPChannelBinding : ChannelBinding { "queue", (a, n) => { a.Queue = n.ParseMap(QueueFixedFields); } }, }; - private static FixedFieldMap ExchangeFixedFields = new () + private static FixedFieldMap ExchangeFixedFields = new() { { "name", (a, n) => { a.Name = n.GetScalarValue(); } }, { "durable", (a, n) => { a.Durable = n.GetBooleanValue(); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/AMQP/AMQPMessageBinding.cs b/src/LEGO.AsyncAPI.Bindings/AMQP/AMQPMessageBinding.cs index 17642020..73a68049 100644 --- a/src/LEGO.AsyncAPI.Bindings/AMQP/AMQPMessageBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/AMQP/AMQPMessageBinding.cs @@ -41,7 +41,7 @@ public override void SerializeProperties(IAsyncApiWriter writer) public override string BindingKey => "amqp"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "contentEncoding", (a, n) => { a.ContentEncoding = n.GetScalarValue(); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/Http/HttpMessageBinding.cs b/src/LEGO.AsyncAPI.Bindings/Http/HttpMessageBinding.cs index ea9f6f95..7a5731ef 100644 --- a/src/LEGO.AsyncAPI.Bindings/Http/HttpMessageBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Http/HttpMessageBinding.cs @@ -13,7 +13,6 @@ namespace LEGO.AsyncAPI.Bindings.Http /// public class HttpMessageBinding : MessageBinding { - /// /// A Schema object containing the definitions for HTTP-specific headers. This schema MUST be of type object and have a properties key. /// @@ -40,11 +39,10 @@ public override void SerializeProperties(IAsyncApiWriter writer) public override string BindingKey => "http"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "headers", (a, n) => { a.Headers = JsonSchemaDeserializer.LoadSchema(n); } }, }; - } } diff --git a/src/LEGO.AsyncAPI.Bindings/Http/HttpOperationBinding.cs b/src/LEGO.AsyncAPI.Bindings/Http/HttpOperationBinding.cs index d41bbafb..f70858c2 100644 --- a/src/LEGO.AsyncAPI.Bindings/Http/HttpOperationBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Http/HttpOperationBinding.cs @@ -58,7 +58,7 @@ public override void SerializeProperties(IAsyncApiWriter writer) writer.WriteEndObject(); } - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "type", (a, n) => { a.Type = n.GetScalarValue().GetEnumFromDisplayName(); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaChannelBinding.cs b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaChannelBinding.cs index 80e07891..90b7c6ff 100644 --- a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaChannelBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaChannelBinding.cs @@ -34,7 +34,7 @@ public class KafkaChannelBinding : ChannelBinding public override string BindingKey => "kafka"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "topic", (a, n) => { a.Topic = n.GetScalarValue(); } }, @@ -43,7 +43,7 @@ public class KafkaChannelBinding : ChannelBinding { "replicas", (a, n) => { a.Replicas = n.GetIntegerValue(); } }, }; - private static FixedFieldMap kafkaChannelTopicConfigurationObjectFixedFields = new () + private static FixedFieldMap kafkaChannelTopicConfigurationObjectFixedFields = new() { { "cleanup.policy", (a, n) => { a.CleanupPolicy = n.CreateSimpleList(s => s.GetScalarValue()); } }, { "retention.ms", (a, n) => { a.RetentionMilliseconds = n.GetLongValue(); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaMessageBinding.cs b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaMessageBinding.cs index 85062422..2f665560 100644 --- a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaMessageBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaMessageBinding.cs @@ -36,7 +36,7 @@ public class KafkaMessageBinding : MessageBinding /// /// The version of this binding. If omitted, "latest" MUST be assumed. /// - + public override void SerializeProperties(IAsyncApiWriter writer) { if (writer is null) @@ -62,9 +62,9 @@ public override void SerializeProperties(IAsyncApiWriter writer) /// The writer. /// writer. - public override string BindingKey => "kafka"; + public override string BindingKey => "kafka"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "key", (a, n) => { a.Key = JsonSchemaDeserializer.LoadSchema(n); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaOperationBinding.cs b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaOperationBinding.cs index 5ae7ba8f..53db7ae0 100644 --- a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaOperationBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaOperationBinding.cs @@ -25,7 +25,7 @@ public class KafkaOperationBinding : OperationBinding public override string BindingKey => "kafka"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "groupId", (a, n) => { a.GroupId = JsonSchemaDeserializer.LoadSchema(n); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaServerBinding.cs b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaServerBinding.cs index 0ee3bc5d..c679d46b 100644 --- a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaServerBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaServerBinding.cs @@ -24,7 +24,7 @@ public class KafkaServerBinding : ServerBinding public override string BindingKey => "kafka"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "schemaRegistryUrl", (a, n) => { a.SchemaRegistryUrl = n.GetScalarValue(); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/LEGO.AsyncAPI.Bindings.csproj b/src/LEGO.AsyncAPI.Bindings/LEGO.AsyncAPI.Bindings.csproj index 751ea5c6..dc76c2ba 100644 --- a/src/LEGO.AsyncAPI.Bindings/LEGO.AsyncAPI.Bindings.csproj +++ b/src/LEGO.AsyncAPI.Bindings/LEGO.AsyncAPI.Bindings.csproj @@ -1,5 +1,5 @@  - + AsyncAPI.NET Bindings AsyncAPI.NET.Bindings @@ -15,7 +15,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/LEGO.AsyncAPI.Bindings/MQTT/MQTTMessageBinding.cs b/src/LEGO.AsyncAPI.Bindings/MQTT/MQTTMessageBinding.cs index fdee2114..b48e5ae9 100644 --- a/src/LEGO.AsyncAPI.Bindings/MQTT/MQTTMessageBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/MQTT/MQTTMessageBinding.cs @@ -54,7 +54,7 @@ public override void SerializeProperties(IAsyncApiWriter writer) public override string BindingKey => "mqtt"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "payloadFormatIndicator", (a, n) => { a.PayloadFormatIndicator = n.GetIntegerValueOrDefault(); } }, { "correlationData", (a, n) => { a.CorrelationData = JsonSchemaDeserializer.LoadSchema(n); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/MQTT/MQTTServerBinding.cs b/src/LEGO.AsyncAPI.Bindings/MQTT/MQTTServerBinding.cs index c37b12e3..03b88b23 100644 --- a/src/LEGO.AsyncAPI.Bindings/MQTT/MQTTServerBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/MQTT/MQTTServerBinding.cs @@ -49,7 +49,7 @@ public class MQTTServerBinding : ServerBinding public override string BindingKey => "mqtt"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "clientId", (a, n) => { a.ClientId = n.GetScalarValue(); } }, @@ -60,7 +60,7 @@ public class MQTTServerBinding : ServerBinding { "maximumPacketSize", (a, n) => { a.MaximumPacketSize = n.GetIntegerValueOrDefault(); } }, }; - private static FixedFieldMap LastWillFixedFields = new () + private static FixedFieldMap LastWillFixedFields = new() { { "topic", (a, n) => { a.Topic = n.GetScalarValue(); } }, { "qos", (a, n) => { a.QoS = (uint?)n.GetIntegerValueOrDefault(); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/OperationBinding{T}.cs b/src/LEGO.AsyncAPI.Bindings/OperationBinding{T}.cs index 0e4216ed..626250ee 100644 --- a/src/LEGO.AsyncAPI.Bindings/OperationBinding{T}.cs +++ b/src/LEGO.AsyncAPI.Bindings/OperationBinding{T}.cs @@ -6,7 +6,7 @@ namespace LEGO.AsyncAPI.Bindings using LEGO.AsyncAPI.Readers; using LEGO.AsyncAPI.Readers.ParseNodes; - public abstract class OperationBinding : Binding , IOperationBinding + public abstract class OperationBinding : Binding, IOperationBinding where T : IOperationBinding, new() { protected abstract FixedFieldMap FixedFieldMap { get; } diff --git a/src/LEGO.AsyncAPI.Bindings/Pulsar/PulsarChannelBinding.cs b/src/LEGO.AsyncAPI.Bindings/Pulsar/PulsarChannelBinding.cs index bc30f9a9..c673a8e8 100644 --- a/src/LEGO.AsyncAPI.Bindings/Pulsar/PulsarChannelBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Pulsar/PulsarChannelBinding.cs @@ -68,7 +68,7 @@ public override void SerializeProperties(IAsyncApiWriter writer) writer.WriteEndObject(); } - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "namespace", (a, n) => { a.Namespace = n.GetScalarValue(); } }, @@ -80,7 +80,7 @@ public override void SerializeProperties(IAsyncApiWriter writer) { "deduplication", (a, n) => { a.Deduplication = n.GetBooleanValue(); } }, }; - private FixedFieldMap pulsarServerBindingRetentionFixedFields = new () + private FixedFieldMap pulsarServerBindingRetentionFixedFields = new() { { "time", (a, n) => { a.Time = n.GetIntegerValue(); } }, { "size", (a, n) => { a.Size = n.GetIntegerValue(); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/Pulsar/PulsarServerBinding.cs b/src/LEGO.AsyncAPI.Bindings/Pulsar/PulsarServerBinding.cs index 1a102d71..e767443d 100644 --- a/src/LEGO.AsyncAPI.Bindings/Pulsar/PulsarServerBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Pulsar/PulsarServerBinding.cs @@ -19,7 +19,7 @@ public class PulsarServerBinding : ServerBinding public override string BindingKey => "pulsar"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "tenant", (a, n) => { a.Tenant = n.GetScalarValue(); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/Consumer.cs b/src/LEGO.AsyncAPI.Bindings/Sns/Consumer.cs index 262521d0..688c186f 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/Consumer.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/Consumer.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns { using System; @@ -24,7 +26,7 @@ public class Consumer : IAsyncApiExtensible /// Depending on the FilterPolicyScope, a map of either a message attribute or message body to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint. /// public AsyncApiAny FilterPolicy { get; set; } - + /// /// Determines whether the FilterPolicy applies to MessageAttributes or MessageBody. /// @@ -85,7 +87,7 @@ public enum Protocol [Display("lambda")] Lambda, [Display("firehose")] Firehose, } - + public enum FilterPolicyScope { [Display("MessageAttributes")] MessageAttributes, diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/DeliveryPolicy.cs b/src/LEGO.AsyncAPI.Bindings/Sns/DeliveryPolicy.cs index f9421ca9..9ed78b19 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/DeliveryPolicy.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/DeliveryPolicy.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/Identifier.cs b/src/LEGO.AsyncAPI.Bindings/Sns/Identifier.cs index 0e6466b0..960c1c54 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/Identifier.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/Identifier.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/Ordering.cs b/src/LEGO.AsyncAPI.Bindings/Sns/Ordering.cs index f80c953b..23f69f52 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/Ordering.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/Ordering.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/Policy.cs b/src/LEGO.AsyncAPI.Bindings/Sns/Policy.cs index eefc6171..a4232e5e 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/Policy.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/Policy.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/RedrivePolicy.cs b/src/LEGO.AsyncAPI.Bindings/Sns/RedrivePolicy.cs index 4e5e6340..01e6d7e2 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/RedrivePolicy.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/RedrivePolicy.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/SnsChannelBinding.cs b/src/LEGO.AsyncAPI.Bindings/Sns/SnsChannelBinding.cs index 65043449..13676168 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/SnsChannelBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/SnsChannelBinding.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/SnsOperationBinding.cs b/src/LEGO.AsyncAPI.Bindings/Sns/SnsOperationBinding.cs index ffab9afb..350b7a59 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/SnsOperationBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/SnsOperationBinding.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns { using System; @@ -43,7 +45,7 @@ public class SnsOperationBinding : OperationBinding { "name", (a, n) => { a.Name = n.GetScalarValue(); } }, }; - private FixedFieldMap consumerFixedFields => new () + private FixedFieldMap consumerFixedFields => new() { { "protocol", (a, n) => { a.Protocol = n.GetScalarValue().GetEnumFromDisplayName(); } }, { "endpoint", (a, n) => { a.Endpoint = n.ParseMapWithExtensions(this.identifierFixFields); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs b/src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs index 38e0b1ee..7f3771f0 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns { using System; @@ -8,7 +10,6 @@ namespace LEGO.AsyncAPI.Bindings.Sns public class Statement : IAsyncApiExtensible { - public Effect Effect { get; set; } /// diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/Identifier.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/Identifier.cs index d7d95dcc..6e7aff23 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/Identifier.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/Identifier.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sqs { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/Policy.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/Policy.cs index a989c239..2fd9f68b 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/Policy.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/Policy.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sqs { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs index 4eec17ef..33166af5 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sqs { using System; @@ -26,7 +28,7 @@ public class Queue : IAsyncApiExtensible /// /// Specifies whether the FIFO queue throughput quota applies to the entire queue or per message group. Valid values are perQueue (default) and perMessageGroupId. /// - public FifoThroughputLimit? FifoThroughputLimit { get; set; } + public FifoThroughputLimit? FifoThroughputLimit { get; set; } /// /// The number of seconds to delay before a message sent to the queue can be received. used to create a delay queue. diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/RedrivePolicy.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/RedrivePolicy.cs index 4222ee45..923d668c 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/RedrivePolicy.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/RedrivePolicy.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sqs { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs index b64bed31..6f98da99 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sqs { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs index de2372f1..d8eb43dd 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sqs { using System; diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/Statement.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/Statement.cs index 508e4a33..9518d2d4 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/Statement.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/Statement.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sqs { using System; @@ -8,7 +10,6 @@ namespace LEGO.AsyncAPI.Bindings.Sqs public class Statement : IAsyncApiExtensible { - public Effect Effect { get; set; } /// diff --git a/src/LEGO.AsyncAPI.Bindings/StringOrStringList.cs b/src/LEGO.AsyncAPI.Bindings/StringOrStringList.cs index c2f323cc..6be69094 100644 --- a/src/LEGO.AsyncAPI.Bindings/StringOrStringList.cs +++ b/src/LEGO.AsyncAPI.Bindings/StringOrStringList.cs @@ -18,7 +18,7 @@ public StringOrStringList(AsyncApiAny value) { 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."), - _ => throw new ArgumentException($"{nameof(StringOrStringList)} should be a string value or a string list.") + _ => throw new ArgumentException($"{nameof(StringOrStringList)} should be a string value or a string list."), }; } @@ -31,15 +31,15 @@ public static StringOrStringList Parse(ParseNode node) case ValueNode: return new StringOrStringList(new AsyncApiAny(node.GetScalarValue())); case ListNode: - { - var jsonArray = new JsonArray(); - foreach (var item in node as ListNode) { - jsonArray.Add(item.GetScalarValue()); - } + var jsonArray = new JsonArray(); + foreach (var item in node as ListNode) + { + jsonArray.Add(item.GetScalarValue()); + } - return new StringOrStringList(new AsyncApiAny(jsonArray)); - } + return new StringOrStringList(new AsyncApiAny(jsonArray)); + } default: throw new ArgumentException($"An error occured while parsing a {nameof(StringOrStringList)} node. " + diff --git a/src/LEGO.AsyncAPI.Bindings/WebSockets/WebSocketsChannelBinding.cs b/src/LEGO.AsyncAPI.Bindings/WebSockets/WebSocketsChannelBinding.cs index a3fb6366..c87393bb 100644 --- a/src/LEGO.AsyncAPI.Bindings/WebSockets/WebSocketsChannelBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/WebSockets/WebSocketsChannelBinding.cs @@ -25,9 +25,9 @@ public class WebSocketsChannelBinding : ChannelBinding /// public AsyncApiSchema Headers { get; set; } - public override string BindingKey => "websockets"; + public override string BindingKey => "websockets"; - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } }, { "method", (a, n) => { a.Method = n.GetScalarValue(); } }, diff --git a/src/LEGO.AsyncAPI.Readers/AsyncApiJsonDocumentReader.cs b/src/LEGO.AsyncAPI.Readers/AsyncApiJsonDocumentReader.cs index fbce6668..aca50c17 100644 --- a/src/LEGO.AsyncAPI.Readers/AsyncApiJsonDocumentReader.cs +++ b/src/LEGO.AsyncAPI.Readers/AsyncApiJsonDocumentReader.cs @@ -119,26 +119,6 @@ public async Task ReadAsync(JsonNode input, CancellationToken cancel }; } - private void ResolveReferences(AsyncApiDiagnostic diagnostic, AsyncApiDocument document) - { - var errors = new List(); - - // Resolve References if requested - switch (this.settings.ReferenceResolution) - { - case ReferenceResolutionSetting.ResolveReferences: - errors.AddRange(document.ResolveReferences()); - break; - case ReferenceResolutionSetting.DoNotResolveReferences: - break; - } - - foreach (var item in errors) - { - diagnostic.Errors.Add(item); - } - } - /// /// Reads the stream input and parses the fragment of an AsyncApi description into an AsyncApi Element. /// @@ -182,5 +162,26 @@ public T ReadFragment(JsonNode input, AsyncApiVersion version, out AsyncApiDi return (T)element; } + + private void ResolveReferences(AsyncApiDiagnostic diagnostic, AsyncApiDocument document) + { + var errors = new List(); + + // Resolve References if requested + switch (this.settings.ReferenceResolution) + { + case ReferenceResolutionSetting.ResolveReferences: + errors.AddRange(document.ResolveReferences()); + break; + + case ReferenceResolutionSetting.DoNotResolveReferences: + break; + } + + foreach (var item in errors) + { + diagnostic.Errors.Add(item); + } + } } -} +} \ No newline at end of file diff --git a/src/LEGO.AsyncAPI.Readers/BindingDeserializer.cs b/src/LEGO.AsyncAPI.Readers/BindingDeserializer.cs index 441e0935..5744985d 100644 --- a/src/LEGO.AsyncAPI.Readers/BindingDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/BindingDeserializer.cs @@ -22,7 +22,7 @@ public static T LoadBinding(string nodeName, ParseNode node, FixedFieldMap private static PatternFieldMap BindingPatternExtensionFields() where T : IBinding, new() { - return new () + return new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, AsyncApiV2Deserializer.LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/Interface/IAsyncApiReader.cs b/src/LEGO.AsyncAPI.Readers/Interface/IAsyncApiReader.cs index 6938ea88..ef2fb45f 100644 --- a/src/LEGO.AsyncAPI.Readers/Interface/IAsyncApiReader.cs +++ b/src/LEGO.AsyncAPI.Readers/Interface/IAsyncApiReader.cs @@ -4,7 +4,8 @@ namespace LEGO.AsyncAPI.Readers.Interface { using LEGO.AsyncAPI.Models; - public interface IAsyncApiReader where TDiagnostic : IDiagnostic + public interface IAsyncApiReader + where TDiagnostic : IDiagnostic { AsyncApiDocument Read(TInput input, out TDiagnostic diagnostic); } diff --git a/src/LEGO.AsyncAPI.Readers/Interface/IAsyncApiVersionService.cs b/src/LEGO.AsyncAPI.Readers/Interface/IAsyncApiVersionService.cs index 61922eef..c2345ac1 100644 --- a/src/LEGO.AsyncAPI.Readers/Interface/IAsyncApiVersionService.cs +++ b/src/LEGO.AsyncAPI.Readers/Interface/IAsyncApiVersionService.cs @@ -10,7 +10,8 @@ internal interface IAsyncApiVersionService { AsyncApiReference ConvertToAsyncApiReference(string reference, ReferenceType? type); - T LoadElement(ParseNode node) where T : IAsyncApiElement; + T LoadElement(ParseNode node) + where T : IAsyncApiElement; AsyncApiDocument LoadDocument(RootNode rootNode); } diff --git a/src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj b/src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj index b0164afd..c47530c0 100644 --- a/src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj +++ b/src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj @@ -1,5 +1,5 @@  - + disable AsyncAPI.NET Readers for JSON and YAML documents @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/LEGO.AsyncAPI.Readers/ParseNodes/MapNode.cs b/src/LEGO.AsyncAPI.Readers/ParseNodes/MapNode.cs index 508a6cdd..a9bf1c48 100644 --- a/src/LEGO.AsyncAPI.Readers/ParseNodes/MapNode.cs +++ b/src/LEGO.AsyncAPI.Readers/ParseNodes/MapNode.cs @@ -201,7 +201,7 @@ public string GetReferencePointer() public string GetScalarValue(ValueNode key) { - var scalarNode = this.node[key.GetScalarValue()] is JsonValue jsonValue + var scalarNode = this.node[key.GetScalarValue()] is JsonValue jsonValue ? jsonValue : throw new AsyncApiReaderException($"Expected scalar value while parsing {key.GetScalarValue()}", this.Context); diff --git a/src/LEGO.AsyncAPI.Readers/ParsingContext.cs b/src/LEGO.AsyncAPI.Readers/ParsingContext.cs index 91f35d4a..812a2fe2 100644 --- a/src/LEGO.AsyncAPI.Readers/ParsingContext.cs +++ b/src/LEGO.AsyncAPI.Readers/ParsingContext.cs @@ -15,7 +15,7 @@ namespace LEGO.AsyncAPI.Readers public class ParsingContext { - private readonly Stack currentLocation = new (); + private readonly Stack currentLocation = new(); internal Dictionary> ExtensionParsers { @@ -23,19 +23,19 @@ internal Dictionary> ExtensionPars set; } - = new (); + = new(); - internal Dictionary> ServerBindingParsers { get; set; } = new (); + internal Dictionary> ServerBindingParsers { get; set; } = new(); - internal Dictionary> ChannelBindingParsers { get; set; } - - internal Dictionary> OperationBindingParsers { get; set; } = new (); - - internal Dictionary> MessageBindingParsers { get; set; } = new (); + internal Dictionary> ChannelBindingParsers { get; set; } = new(); + + internal Dictionary> OperationBindingParsers { get; set; } = new(); + + internal Dictionary> MessageBindingParsers { get; set; } = new(); internal RootNode RootNode { get; set; } - internal List Tags { get; private set; } = new (); + internal List Tags { get; private set; } = new(); public AsyncApiDiagnostic Diagnostic { get; } @@ -67,7 +67,8 @@ internal AsyncApiDocument Parse(JsonNode jsonNode) return doc; } - internal T ParseFragment(JsonNode jsonNode, AsyncApiVersion version) where T : IAsyncApiElement + internal T ParseFragment(JsonNode jsonNode, AsyncApiVersion version) + where T : IAsyncApiElement { var node = ParseNode.Create(this, jsonNode); @@ -99,7 +100,8 @@ public void EndObject() public string GetLocation() { - return "#/" + string.Join("/", + return "#/" + string.Join( + "/", this.currentLocation.Reverse().Select(s => s.Replace("~", "~0").Replace("/", "~1")).ToArray()); } diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiChannelDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiChannelDeserializer.cs index 8211da1d..cc74e0c0 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiChannelDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiChannelDeserializer.cs @@ -8,7 +8,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static readonly FixedFieldMap ChannelFixedFields = new () + private static readonly FixedFieldMap ChannelFixedFields = new() { { "description", (a, n) => { a.Description = n.GetScalarValue(); } }, { "servers", (a, n) => { a.Servers = n.CreateSimpleList(s => s.GetScalarValue()); } }, @@ -19,7 +19,7 @@ internal static partial class AsyncApiV2Deserializer }; private static readonly PatternFieldMap ChannelPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiComponentsDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiComponentsDeserializer.cs index cda083de..3b63db28 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiComponentsDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiComponentsDeserializer.cs @@ -8,7 +8,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap componentsFixedFields = new () + private static FixedFieldMap componentsFixedFields = new() { { "schemas", (a, n) => a.Schemas = n.CreateMapWithReference(ReferenceType.Schema, JsonSchemaDeserializer.LoadSchema) }, { "servers", (a, n) => a.Servers = n.CreateMapWithReference(ReferenceType.Server, LoadServer) }, @@ -26,7 +26,7 @@ internal static partial class AsyncApiV2Deserializer }; private static PatternFieldMap componentsPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiContactDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiContactDeserializer.cs index 09672719..1a02ffaa 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiContactDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiContactDeserializer.cs @@ -13,14 +13,14 @@ namespace LEGO.AsyncAPI.Readers /// internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap contactFixedFields = new () + private static FixedFieldMap contactFixedFields = new() { { "name", (o, n) => { o.Name = n.GetScalarValue(); } }, { "email", (o, n) => { o.Email = n.GetScalarValue(); } }, { "url", (o, n) => { o.Url = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); } }, }; - private static PatternFieldMap contactPatternFields = new () + private static PatternFieldMap contactPatternFields = new() { { s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiCorrelationIdDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiCorrelationIdDeserializer.cs index aaf30093..0b8e88f0 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiCorrelationIdDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiCorrelationIdDeserializer.cs @@ -13,14 +13,14 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { private static readonly FixedFieldMap correlationIdFixedFileds = - new () + new() { { "description", (a, n) => { a.Description = n.GetScalarValue(); } }, { "location", (a, n) => { a.Location = n.GetScalarValue(); } }, }; private static readonly PatternFieldMap correlationIdPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiDocumentDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiDocumentDeserializer.cs index 9daf6418..e7f0289e 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiDocumentDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiDocumentDeserializer.cs @@ -8,7 +8,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap asyncApiFixedFields = new () + private static FixedFieldMap asyncApiFixedFields = new() { { "asyncapi", (a, n) => { a.Asyncapi = "2.6.0"; } }, { "id", (a, n) => a.Id = n.GetScalarValue() }, @@ -21,7 +21,7 @@ internal static partial class AsyncApiV2Deserializer { "externalDocs", (a, n) => a.ExternalDocs = LoadExternalDocs(n) }, }; - private static PatternFieldMap asyncApiPatternFields = new () + private static PatternFieldMap asyncApiPatternFields = new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiExampleDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiExampleDeserializer.cs index b8f80257..46667a4b 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiExampleDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiExampleDeserializer.cs @@ -8,7 +8,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap exampleFixedFields = new () + private static FixedFieldMap exampleFixedFields = new() { { "headers", (a, n) => { a.Headers = n.CreateMap(LoadAny); } }, { "payload", (a, n) => { a.Payload = n.CreateAny(); } }, @@ -17,7 +17,7 @@ internal static partial class AsyncApiV2Deserializer }; private static PatternFieldMap examplePatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiExternalDocsDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiExternalDocsDeserializer.cs index 824fa26a..2c5e07b6 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiExternalDocsDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiExternalDocsDeserializer.cs @@ -9,14 +9,14 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap externalDocumentationFixedFields = new () + private static FixedFieldMap externalDocumentationFixedFields = new() { { "description", (a, n) => { a.Description = n.GetScalarValue(); } }, { "url", (a, n) => { a.Url = new Uri(n.GetScalarValue()); } }, }; private static PatternFieldMap externalDocumentationPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiInfoDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiInfoDeserializer.cs index c9c745dd..60a359f5 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiInfoDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiInfoDeserializer.cs @@ -9,7 +9,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap infoFixedFields = new () + private static FixedFieldMap infoFixedFields = new() { { "title", (a, n) => { a.Title = n.GetScalarValue(); } }, { "version", (a, n) => { a.Version = n.GetScalarValue(); } }, @@ -20,7 +20,7 @@ internal static partial class AsyncApiV2Deserializer }; private static PatternFieldMap infoPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiLicenseDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiLicenseDeserializer.cs index 28c2fb8d..630d2efc 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiLicenseDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiLicenseDeserializer.cs @@ -9,14 +9,14 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap licenseFixedFields = new () + private static FixedFieldMap licenseFixedFields = new() { { "name", (a, n) => { a.Name = n.GetScalarValue(); } }, { "url", (a, n) => { a.Url = new Uri(n.GetScalarValue()); } }, }; private static PatternFieldMap licensePatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageDeserializer.cs index 4c65a019..4c16bf22 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageDeserializer.cs @@ -15,7 +15,7 @@ namespace LEGO.AsyncAPI.Readers /// internal static partial class AsyncApiV2Deserializer { - private static readonly FixedFieldMap messageFixedFields = new () + private static readonly FixedFieldMap messageFixedFields = new() { { "messageId", (a, n) => { a.MessageId = n.GetScalarValue(); } @@ -83,7 +83,7 @@ private static string LoadSchemaFormat(string schemaFormat) return schemaFormat; } - private static readonly PatternFieldMap messagePatternFields = new () + private static readonly PatternFieldMap messagePatternFields = new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageTraitDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageTraitDeserializer.cs index 67de4bcd..eca8af64 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageTraitDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageTraitDeserializer.cs @@ -8,7 +8,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap messageTraitFixedFields = new () + private static FixedFieldMap messageTraitFixedFields = new() { { "messageId", (a, n) => { a.MessageId = n.GetScalarValue(); } }, { "headers", (a, n) => { a.Headers = JsonSchemaDeserializer.LoadSchema(n); } }, @@ -26,7 +26,7 @@ internal static partial class AsyncApiV2Deserializer }; private static PatternFieldMap messageTraitPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOAuthFlowDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOAuthFlowDeserializer.cs index dfeb3d83..cddb8126 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOAuthFlowDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOAuthFlowDeserializer.cs @@ -14,7 +14,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { private static readonly FixedFieldMap oAuthFlowFixedFields = - new () + new() { { "authorizationUrl", (o, n) => @@ -38,7 +38,7 @@ internal static partial class AsyncApiV2Deserializer }; private static readonly PatternFieldMap oAuthFlowPatternFields = - new () + new() { { s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, LoadExtension(p,n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOAuthFlowsDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOAuthFlowsDeserializer.cs index 8f3a1ce3..dba5ab09 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOAuthFlowsDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOAuthFlowsDeserializer.cs @@ -13,7 +13,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { private static readonly FixedFieldMap oAuthFlowsFixedFileds = - new () + new() { { "implicit", (a, n) => a.Implicit = LoadOAuthFlow(n) }, { "password", (a, n) => a.Password = LoadOAuthFlow(n) }, @@ -22,7 +22,7 @@ internal static partial class AsyncApiV2Deserializer }; private static readonly PatternFieldMap oAuthFlowsPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationDeserializer.cs index 723a20fa..8a9a0505 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationDeserializer.cs @@ -10,7 +10,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { private static readonly FixedFieldMap operationFixedFields = - new () + new() { { "operationId", (a, n) => { a.OperationId = n.GetScalarValue(); } @@ -54,7 +54,7 @@ private static IList LoadMessages(ParseNode n) } private static readonly PatternFieldMap operationPatternFields = - new () + new() { { s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationTraitDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationTraitDeserializer.cs index 1cb1629f..561456e9 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationTraitDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationTraitDeserializer.cs @@ -8,7 +8,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap operationTraitFixedFields = new () + private static FixedFieldMap operationTraitFixedFields = new() { { "operationId", (a, n) => { a.OperationId = n.GetScalarValue(); } }, { "summary", (a, n) => { a.Summary = n.GetScalarValue(); } }, @@ -19,7 +19,7 @@ internal static partial class AsyncApiV2Deserializer }; private static PatternFieldMap operationTraitPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; @@ -33,6 +33,7 @@ public static AsyncApiOperationTrait LoadOperationTrait(ParseNode node) { return mapNode.GetReferencedObject(ReferenceType.OperationTrait, pointer); } + var operationTrait = new AsyncApiOperationTrait(); ParseMap(mapNode, operationTrait, operationTraitFixedFields, operationTraitPatternFields); diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiParameterDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiParameterDeserializer.cs index e9ef5e51..bff810f1 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiParameterDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiParameterDeserializer.cs @@ -8,7 +8,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap parameterFixedFields = new () + private static FixedFieldMap parameterFixedFields = new() { { "description", (a, n) => { a.Description = n.GetScalarValue(); } }, { "schema", (a, n) => { a.Schema = JsonSchemaDeserializer.LoadSchema(n); } }, @@ -16,7 +16,7 @@ internal static partial class AsyncApiV2Deserializer }; private static PatternFieldMap parameterPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs index 2131eb7e..04c51f52 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs @@ -11,7 +11,7 @@ namespace LEGO.AsyncAPI.Readers public class JsonSchemaDeserializer { - private static readonly FixedFieldMap schemaFixedFields = new () + private static readonly FixedFieldMap schemaFixedFields = new() { { "title", (a, n) => { a.Title = n.GetScalarValue(); } @@ -23,6 +23,7 @@ public class JsonSchemaDeserializer { a.Type = n.GetScalarValue().GetEnumFromDisplayName(); } + if (n.GetType() == typeof(ListNode)) { SchemaType? initialValue = null; @@ -209,12 +210,12 @@ public class JsonSchemaDeserializer }; private static readonly PatternFieldMap schemaPatternFields = - new () + new() { { s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, AsyncApiV2Deserializer.LoadExtension(p, n)) }, }; - private static readonly AnyFieldMap schemaAnyFields = new () + private static readonly AnyFieldMap schemaAnyFields = new() { { AsyncApiConstants.Default, @@ -225,7 +226,7 @@ public class JsonSchemaDeserializer }, }; - private static readonly AnyListFieldMap schemaAnyListFields = new () + private static readonly AnyListFieldMap schemaAnyListFields = new() { { AsyncApiConstants.Enum, diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSecuritySchemeDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSecuritySchemeDeserializer.cs index 10ce26d7..92708116 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSecuritySchemeDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSecuritySchemeDeserializer.cs @@ -15,7 +15,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { private static readonly FixedFieldMap securitySchemeFixedFields = - new () + new() { { "type", (o, n) => { o.Type = n.GetScalarValue().GetEnumFromDisplayName(); } @@ -45,7 +45,7 @@ internal static partial class AsyncApiV2Deserializer }; private static readonly PatternFieldMap securitySchemePatternFields = - new () + new() { { s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiServerDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiServerDeserializer.cs index 2dffe850..6eae00af 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiServerDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiServerDeserializer.cs @@ -12,7 +12,7 @@ namespace LEGO.AsyncAPI.Readers /// internal static partial class AsyncApiV2Deserializer { - private static readonly FixedFieldMap serverFixedFields = new () + private static readonly FixedFieldMap serverFixedFields = new() { { "url", (a, n) => { a.Url = n.GetScalarValue(); } @@ -41,7 +41,7 @@ internal static partial class AsyncApiV2Deserializer }; private static readonly PatternFieldMap serverPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiServerVariableDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiServerVariableDeserializer.cs index 4a4c0db5..b773d255 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiServerVariableDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiServerVariableDeserializer.cs @@ -13,7 +13,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { private static readonly FixedFieldMap serverVariableFixedFields = - new () + new() { { "enum", (a, n) => { a.Enum = n.CreateSimpleList(s => s.GetScalarValue()); } @@ -30,7 +30,7 @@ internal static partial class AsyncApiV2Deserializer }; private static readonly PatternFieldMap serverVariablePatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiTagDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiTagDeserializer.cs index 9f38c01c..cc589fa2 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiTagDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiTagDeserializer.cs @@ -8,7 +8,7 @@ namespace LEGO.AsyncAPI.Readers internal static partial class AsyncApiV2Deserializer { - private static FixedFieldMap tagsFixedFields = new () + private static FixedFieldMap tagsFixedFields = new() { { "name", (a, n) => { a.Name = n.GetScalarValue(); } }, { "description", (a, n) => { a.Description = n.GetScalarValue(); } }, @@ -16,7 +16,7 @@ internal static partial class AsyncApiV2Deserializer }; private static PatternFieldMap tagsPatternFields = - new () + new() { { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, }; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiV2VersionService.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiV2VersionService.cs index 3c99409c..10edd3ba 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiV2VersionService.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiV2VersionService.cs @@ -81,7 +81,6 @@ public AsyncApiReference ConvertToAsyncApiReference( asyncApiReference.ExternalResource = segments[0]; return asyncApiReference; - } else if (segments.Length == 2) { @@ -139,7 +138,8 @@ public AsyncApiDocument LoadDocument(RootNode rootNode) return AsyncApiV2Deserializer.LoadAsyncApi(rootNode); } - public T LoadElement(ParseNode node) where T : IAsyncApiElement + public T LoadElement(ParseNode node) + where T : IAsyncApiElement { return (T)this.loaders[typeof(T)](node); } diff --git a/src/LEGO.AsyncAPI.Readers/V2/ExtensionHelpers.cs b/src/LEGO.AsyncAPI.Readers/V2/ExtensionHelpers.cs index a134c46d..60689b31 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/ExtensionHelpers.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/ExtensionHelpers.cs @@ -10,9 +10,10 @@ namespace LEGO.AsyncAPI.Readers public static class ExtensionHelpers { - public static PatternFieldMap GetExtensionsFieldMap() where T : IAsyncApiExtensible + public static PatternFieldMap GetExtensionsFieldMap() + where T : IAsyncApiExtensible { - return new () + return new() { { s => s.StartsWith("x-"), diff --git a/src/LEGO.AsyncAPI.Readers/YamlConverter.cs b/src/LEGO.AsyncAPI.Readers/YamlConverter.cs index e3dfcd43..295fb573 100644 --- a/src/LEGO.AsyncAPI.Readers/YamlConverter.cs +++ b/src/LEGO.AsyncAPI.Readers/YamlConverter.cs @@ -1,4 +1,6 @@ -namespace LEGO.AsyncAPI.Readers +// Copyright (c) The LEGO Group. All rights reserved. + +namespace LEGO.AsyncAPI.Readers { using System; using System.Globalization; @@ -43,7 +45,7 @@ public static JsonNode ToJsonNode(this YamlNode yaml) YamlMappingNode map => map.ToJsonObject(), YamlSequenceNode seq => seq.ToJsonArray(), YamlScalarNode scalar => scalar.ToJsonValue(), - _ => throw new NotSupportedException("This yaml isn't convertible to JSON") + _ => throw new NotSupportedException("This yaml isn't convertible to JSON"), }; } diff --git a/src/LEGO.AsyncAPI/EnumExtensions.cs b/src/LEGO.AsyncAPI/EnumExtensions.cs index 56a46874..3cca149d 100644 --- a/src/LEGO.AsyncAPI/EnumExtensions.cs +++ b/src/LEGO.AsyncAPI/EnumExtensions.cs @@ -18,7 +18,8 @@ public static class EnumExtensions /// /// The attribute of the specified type or null. /// - public static T GetAttributeOfType(this Enum enumValue) where T : Attribute + public static T GetAttributeOfType(this Enum enumValue) + where T : Attribute { var type = enumValue.GetType(); var memInfo = type.GetMember(enumValue.ToString()).First(); diff --git a/src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj b/src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj index c2dd1598..c26d0242 100644 --- a/src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj +++ b/src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj @@ -1,5 +1,5 @@  - + AsyncAPI.NET models AsyncAPI.NET @@ -15,7 +15,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/LEGO.AsyncAPI/Models/Any/AsyncAPIArray.cs b/src/LEGO.AsyncAPI/Models/Any/AsyncAPIArray.cs index 01970b19..d40208bd 100644 --- a/src/LEGO.AsyncAPI/Models/Any/AsyncAPIArray.cs +++ b/src/LEGO.AsyncAPI/Models/Any/AsyncAPIArray.cs @@ -11,7 +11,6 @@ namespace LEGO.AsyncAPI.Models [Obsolete("Please use AsyncApiAny instead")] public class AsyncApiArray : Collection, IAsyncApiExtension, IAsyncApiElement { - public static explicit operator AsyncApiArray(AsyncApiAny any) { var a = new AsyncApiArray(); diff --git a/src/LEGO.AsyncAPI/Models/Any/AsyncAPIObject.cs b/src/LEGO.AsyncAPI/Models/Any/AsyncAPIObject.cs index e93f595e..7f87ac2e 100644 --- a/src/LEGO.AsyncAPI/Models/Any/AsyncAPIObject.cs +++ b/src/LEGO.AsyncAPI/Models/Any/AsyncAPIObject.cs @@ -14,7 +14,6 @@ namespace LEGO.AsyncAPI.Models [Obsolete("Please use AsyncApiAny instead")] public class AsyncApiObject : Dictionary, IAsyncApiExtension, IAsyncApiElement { - public static implicit operator AsyncApiAny(AsyncApiObject obj) { var jObject = new JsonObject(); diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiBindings.cs b/src/LEGO.AsyncAPI/Models/AsyncApiBindings.cs index cf382b63..6aaa389a 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiBindings.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiBindings.cs @@ -48,7 +48,6 @@ public void Add(TBinding binding) public void SerializeV2(IAsyncApiWriter writer) { - if (writer is null) { throw new ArgumentNullException(nameof(writer)); diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs b/src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs index 1a5b7c71..5be55202 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs @@ -145,7 +145,8 @@ public IEnumerable ResolveReferences() return resolver.Errors; } - internal T ResolveReference(AsyncApiReference reference) where T : class, IAsyncApiReferenceable + internal T ResolveReference(AsyncApiReference reference) + where T : class, IAsyncApiReferenceable { return this.ResolveReference(reference) as T; } diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiSerializableExtensions.cs b/src/LEGO.AsyncAPI/Models/AsyncApiSerializableExtensions.cs index 8d444df0..eea342c4 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiSerializableExtensions.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiSerializableExtensions.cs @@ -119,10 +119,10 @@ public static void Serialize(this T element, IAsyncApiWriter writer, AsyncApi switch (specificationVersion) { case AsyncApiVersion.AsyncApi2_0: - element.SerializeV2(writer); - break; + element.SerializeV2(writer); + break; default: - throw new AsyncApiException($"specification version '{specificationVersion}' is not supported."); + throw new AsyncApiException($"specification version '{specificationVersion}' is not supported."); } writer.Flush(); diff --git a/src/LEGO.AsyncAPI/Models/Interfaces/IBinding.cs b/src/LEGO.AsyncAPI/Models/Interfaces/IBinding.cs index 44e4573d..f39bc06f 100644 --- a/src/LEGO.AsyncAPI/Models/Interfaces/IBinding.cs +++ b/src/LEGO.AsyncAPI/Models/Interfaces/IBinding.cs @@ -6,8 +6,8 @@ namespace LEGO.AsyncAPI.Models.Interfaces /// public interface IBinding : IAsyncApiSerializable, IAsyncApiExtensible { - public string BindingKey { get; } + public string BindingKey { get; } - public string BindingVersion { get; set; } + public string BindingVersion { get; set; } } } diff --git a/src/LEGO.AsyncAPI/Models/JsonSchema/FalseApiSchema.cs b/src/LEGO.AsyncAPI/Models/JsonSchema/FalseApiSchema.cs index 40746fb3..01f313e5 100644 --- a/src/LEGO.AsyncAPI/Models/JsonSchema/FalseApiSchema.cs +++ b/src/LEGO.AsyncAPI/Models/JsonSchema/FalseApiSchema.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Models { /// diff --git a/src/LEGO.AsyncAPI/Models/SecuritySchemeType.cs b/src/LEGO.AsyncAPI/Models/SecuritySchemeType.cs index 02fec71b..d910832c 100644 --- a/src/LEGO.AsyncAPI/Models/SecuritySchemeType.cs +++ b/src/LEGO.AsyncAPI/Models/SecuritySchemeType.cs @@ -27,51 +27,51 @@ public enum SecuritySchemeType /// /// Symmetric Encryption. /// - [Display("symmetricEncryption")]SymmetricEncryption, + [Display("symmetricEncryption")] SymmetricEncryption, /// /// Asymmetric Encryption. /// - [Display("asymmetricEncryption")]AsymmetricEncryption, + [Display("asymmetricEncryption")] AsymmetricEncryption, /// /// Api Key. /// - [Display("httpApiKey")]HttpApiKey, + [Display("httpApiKey")] HttpApiKey, /// /// Basic or Bearer token authorization header. /// - [Display("http")]Http, + [Display("http")] Http, /// /// OAuth2. /// - [Display("oauth2")]OAuth2, + [Display("oauth2")] OAuth2, /// /// OIDC. /// - [Display("openIdConnect")]OpenIdConnect, + [Display("openIdConnect")] OpenIdConnect, /// /// Plain. /// - [Display("plain")]Plain, + [Display("plain")] Plain, /// /// Sha256. /// - [Display("scramSha256")]ScramSha256, + [Display("scramSha256")] ScramSha256, /// /// Sha512. /// - [Display("scramSha512")]ScramSha512, + [Display("scramSha512")] ScramSha512, /// /// GssApi. /// - [Display("gssapi")]Gssapi, + [Display("gssapi")] Gssapi, } } \ No newline at end of file diff --git a/src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs b/src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs index 88808cb8..da6195c6 100644 --- a/src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs +++ b/src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs @@ -154,7 +154,8 @@ public override void Visit(AsyncApiSchema schema) this.ResolveMap(schema.Properties); } - private void ResolveObject(T entity, Action assign) where T : class, IAsyncApiReferenceable, new() + private void ResolveObject(T entity, Action assign) + where T : class, IAsyncApiReferenceable, new() { if (entity == null) { @@ -167,7 +168,8 @@ public override void Visit(AsyncApiSchema schema) } } - private void ResolveList(IList list) where T : class, IAsyncApiReferenceable, new() + private void ResolveList(IList list) + where T : class, IAsyncApiReferenceable, new() { if (list == null) { @@ -184,7 +186,8 @@ public override void Visit(AsyncApiSchema schema) } } - private void ResolveMap(IDictionary map) where T : class, IAsyncApiReferenceable, new() + private void ResolveMap(IDictionary map) + where T : class, IAsyncApiReferenceable, new() { if (map == null) { @@ -201,11 +204,12 @@ public override void Visit(AsyncApiSchema schema) } } - private T ResolveReference(AsyncApiReference reference) where T : class, IAsyncApiReferenceable, new() + private T ResolveReference(AsyncApiReference reference) + where T : class, IAsyncApiReferenceable, new() { if (reference.IsExternal) { - return new () + return new() { UnresolvedReference = true, Reference = reference, diff --git a/src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs b/src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs index e0d3ec38..fc5c5186 100644 --- a/src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs +++ b/src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs @@ -10,7 +10,7 @@ namespace LEGO.AsyncAPI.Services public class AsyncApiWalker { private readonly AsyncApiVisitorBase visitor; - private readonly Stack schemaLoop = new (); + private readonly Stack schemaLoop = new(); public AsyncApiWalker(AsyncApiVisitorBase visitor) { diff --git a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiContactRules.cs b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiContactRules.cs index 93245c22..e42f2ec2 100644 --- a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiContactRules.cs +++ b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiContactRules.cs @@ -48,9 +48,9 @@ private static bool IsEmailAddress(this string input) context.Enter("url"); if (contact != null && contact.Url != null && !contact.Url.IsAbsoluteUri) { - context.CreateError( - nameof(ContactUrlMustBeAbsolute), - string.Format(Resource.Validation_MustBeAbsoluteUrl, "url", "contact")); + context.CreateError( + nameof(ContactUrlMustBeAbsolute), + string.Format(Resource.Validation_MustBeAbsoluteUrl, "url", "contact")); } context.Exit(); diff --git a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiCorrelationIdRules.cs b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiCorrelationIdRules.cs index 3e6a21c8..b401088e 100644 --- a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiCorrelationIdRules.cs +++ b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiCorrelationIdRules.cs @@ -21,7 +21,6 @@ public static class AsyncApiCorrelationIdRules } context.Exit(); - }); } } \ No newline at end of file diff --git a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiExtensionRules.cs b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiExtensionRules.cs index 710b30e5..a2d27039 100644 --- a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiExtensionRules.cs +++ b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiExtensionRules.cs @@ -25,6 +25,7 @@ public static class AsyncApiExtensionRules string.Format(Resource.Validation_ExtensionNameMustBeginWithXDash, extensible.Key, context.PathString)); } } + context.Exit(); }); } diff --git a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiExternalDocumentationRules.cs b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiExternalDocumentationRules.cs index e080e7b4..f5fd53ba 100644 --- a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiExternalDocumentationRules.cs +++ b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiExternalDocumentationRules.cs @@ -21,7 +21,6 @@ public static class AsyncApiExternalDocumentationRules } context.Exit(); - }); public static ValidationRule ExternalDocumentationUrlMustBeAbsolute => @@ -34,7 +33,6 @@ public static class AsyncApiExternalDocumentationRules context.CreateError( nameof(ExternalDocumentationUrlMustBeAbsolute), string.Format(Resource.Validation_MustBeAbsoluteUrl, "url", "externalDocumentation")); - } context.Exit(); diff --git a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiInfoRules.cs b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiInfoRules.cs index 88b9187c..342a1739 100644 --- a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiInfoRules.cs +++ b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiInfoRules.cs @@ -43,7 +43,6 @@ public static class AsyncApiInfoRules context.CreateError( nameof(TermsOfServiceUrlMustBeAbsolute), string.Format(Resource.Validation_MustBeAbsoluteUrl, "termsOfService", "info")); - } context.Exit(); diff --git a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiLicenseRules.cs b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiLicenseRules.cs index 69b8c5ee..0708c13b 100644 --- a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiLicenseRules.cs +++ b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiLicenseRules.cs @@ -27,14 +27,12 @@ public static class AsyncApiLicenseRules new ValidationRule( (context, license) => { - context.Enter("url"); if (license.Url != null && !license.Url.IsAbsoluteUri) { context.CreateError( nameof(LicenseUrlMustBeAbsolute), string.Format(Resource.Validation_MustBeAbsoluteUrl, "url", "license")); - } context.Exit(); diff --git a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiOAuthFlowRules.cs b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiOAuthFlowRules.cs index e1649d4e..457a03ec 100644 --- a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiOAuthFlowRules.cs +++ b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiOAuthFlowRules.cs @@ -42,7 +42,6 @@ public static class AsyncApiOAuthFlowRules } context.Exit(); - }); public static ValidationRule OAuthFlowUrlMustBeAbsolute => @@ -55,7 +54,6 @@ public static class AsyncApiOAuthFlowRules context.CreateError( nameof(OAuthFlowUrlMustBeAbsolute), string.Format(Resource.Validation_MustBeAbsoluteUrl, "authorizationUrl", "flow")); - } context.Exit(); @@ -66,7 +64,6 @@ public static class AsyncApiOAuthFlowRules context.CreateError( nameof(OAuthFlowUrlMustBeAbsolute), string.Format(Resource.Validation_MustBeAbsoluteUrl, "tokenUrl", "flow")); - } context.Exit(); diff --git a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiTagRules.cs b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiTagRules.cs index 244686c5..6e676edb 100644 --- a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiTagRules.cs +++ b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiTagRules.cs @@ -21,7 +21,6 @@ public static class AsyncApiTagRules } context.Exit(); - }); } } \ No newline at end of file diff --git a/src/LEGO.AsyncAPI/Validation/ValidationRule{T}.cs b/src/LEGO.AsyncAPI/Validation/ValidationRule{T}.cs index 6aecdb7a..658183f3 100644 --- a/src/LEGO.AsyncAPI/Validation/ValidationRule{T}.cs +++ b/src/LEGO.AsyncAPI/Validation/ValidationRule{T}.cs @@ -9,7 +9,8 @@ namespace LEGO.AsyncAPI.Validations /// Class containing validation rule logic for . /// /// - public class ValidationRule : ValidationRule where T : IAsyncApiElement + public class ValidationRule : ValidationRule + where T : IAsyncApiElement { private readonly Action validate; diff --git a/src/LEGO.AsyncAPI/Writers/AsyncApiWriterAnyExtensions.cs b/src/LEGO.AsyncAPI/Writers/AsyncApiWriterAnyExtensions.cs index fe2a34a1..9a317cd1 100644 --- a/src/LEGO.AsyncAPI/Writers/AsyncApiWriterAnyExtensions.cs +++ b/src/LEGO.AsyncAPI/Writers/AsyncApiWriterAnyExtensions.cs @@ -174,6 +174,7 @@ private static void WritePrimitive(this IAsyncApiWriter writer, JsonElement prim writer.WriteValue(intValue); } } + if (primitive.ValueKind is JsonValueKind.True or JsonValueKind.False) { writer.WriteValue(primitive.GetBoolean()); diff --git a/src/LEGO.AsyncAPI/Writers/AsyncApiWriterExtensions.cs b/src/LEGO.AsyncAPI/Writers/AsyncApiWriterExtensions.cs index 08025c13..67c4737a 100644 --- a/src/LEGO.AsyncAPI/Writers/AsyncApiWriterExtensions.cs +++ b/src/LEGO.AsyncAPI/Writers/AsyncApiWriterExtensions.cs @@ -93,6 +93,7 @@ public static void WriteOptionalProperty( /// /// Write a primitive property. /// + /// . /// The writer. /// The property name. /// The property value. @@ -110,6 +111,7 @@ public static void WriteOptionalProperty(this IAsyncApiWriter writer, string /// /// Write a string/number property. /// + /// . /// The writer. /// The property name. /// The property value. @@ -280,7 +282,8 @@ public static void WriteRequiredMap( this IAsyncApiWriter writer, string name, IDictionary elements, - Action action) where T : IAsyncApiElement + Action action) + where T : IAsyncApiElement { if (elements != null && elements.Any()) { diff --git a/test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs b/test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs index a598ac18..d73125fb 100644 --- a/test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs +++ b/test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs @@ -20,8 +20,10 @@ namespace LEGO.AsyncAPI.Tests public class ExtensionClass { public string Key { get; set; } + public long OtherKey { get; set; } } + public class AsyncApiDocumentV2Tests { [Test] @@ -200,25 +202,25 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() maximum: 100 minimum: 0"; - var asyncApiDocument = new AsyncApiDocumentBuilder() - .WithInfo(new AsyncApiInfo - { - Title = "Streetlights Kafka API", - Version = "1.0.0", - Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.", - License = new AsyncApiLicense + var asyncApiDocument = new AsyncApiDocumentBuilder() + .WithInfo(new AsyncApiInfo { - Name = "Apache 2.0", - Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0"), - }, - }) - .WithServer("scram-connections", new AsyncApiServer - { - Url = "test.mykafkacluster.org:18092", - Protocol = "kafka-secure", - Description = "Test broker secured with scramSha256", - Security = new List + Title = "Streetlights Kafka API", + Version = "1.0.0", + Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.", + License = new AsyncApiLicense + { + Name = "Apache 2.0", + Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0"), + }, + }) + .WithServer("scram-connections", new AsyncApiServer { + Url = "test.mykafkacluster.org:18092", + Protocol = "kafka-secure", + Description = "Test broker secured with scramSha256", + Security = new List + { new AsyncApiSecurityRequirement { { @@ -232,9 +234,9 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, new List() }, }, - }, - Tags = new List - { + }, + Tags = new List + { new AsyncApiTag { Name = "env:test-scram", @@ -250,15 +252,15 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Name = "visibility:private", Description = "This resource is private and only available to certain users", }, - }, - }) - .WithServer("mtls-connections", new AsyncApiServer - { - Url = "test.mykafkacluster.org:28092", - Protocol = "kafka-secure", - Description = "Test broker secured with X509", - Security = new List + }, + }) + .WithServer("mtls-connections", new AsyncApiServer { + Url = "test.mykafkacluster.org:28092", + Protocol = "kafka-secure", + Description = "Test broker secured with X509", + Security = new List + { new AsyncApiSecurityRequirement { { @@ -272,9 +274,9 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, new List() }, }, - }, - Tags = new List - { + }, + Tags = new List + { new AsyncApiTag { Name = "env:test-mtls", @@ -290,16 +292,16 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Name = "visibility:private", Description = "This resource is private and only available to certain users", }, - }, - }) - .WithDefaultContentType() - .WithChannel( - "smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured", - new AsyncApiChannel() - { - Description = "The topic on which measured values may be produced and consumed.", - Parameters = new Dictionary + }, + }) + .WithDefaultContentType() + .WithChannel( + "smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured", + new AsyncApiChannel() { + Description = "The topic on which measured values may be produced and consumed.", + Parameters = new Dictionary + { { "streetlightId", new AsyncApiParameter() { @@ -310,13 +312,13 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, } }, - }, - Publish = new AsyncApiOperation() - { - Summary = "Inform about environmental lighting conditions of a particular streetlight.", - OperationId = "receiveLightMeasurement", - Traits = new List + }, + Publish = new AsyncApiOperation() { + Summary = "Inform about environmental lighting conditions of a particular streetlight.", + OperationId = "receiveLightMeasurement", + Traits = new List + { new AsyncApiOperationTrait() { Reference = new AsyncApiReference() @@ -325,9 +327,9 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Type = ReferenceType.OperationTrait, }, }, - }, - Message = new List - { + }, + Message = new List + { new AsyncApiMessage() { Reference = new AsyncApiReference() @@ -336,15 +338,15 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Type = ReferenceType.Message, }, }, + }, }, - }, - }) - .WithChannel( - "smartylighting.streetlights.1.0.action.{streetlightId}.turn.on", - new AsyncApiChannel() - { - Parameters = new Dictionary + }) + .WithChannel( + "smartylighting.streetlights.1.0.action.{streetlightId}.turn.on", + new AsyncApiChannel() { + Parameters = new Dictionary + { { "streetlightId", new AsyncApiParameter() { @@ -355,12 +357,12 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, } }, - }, - Subscribe = new AsyncApiOperation() - { - OperationId = "turnOn", - Traits = new List + }, + Subscribe = new AsyncApiOperation() { + OperationId = "turnOn", + Traits = new List + { new AsyncApiOperationTrait() { Reference = new AsyncApiReference() @@ -369,9 +371,9 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Type = ReferenceType.OperationTrait, }, }, - }, - Message = new List - { + }, + Message = new List + { new AsyncApiMessage() { Reference = new AsyncApiReference() @@ -380,15 +382,15 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Type = ReferenceType.Message, }, }, + }, }, - }, - }) - .WithChannel( - "smartylighting.streetlights.1.0.action.{streetlightId}.turn.off", - new AsyncApiChannel() - { - Parameters = new Dictionary + }) + .WithChannel( + "smartylighting.streetlights.1.0.action.{streetlightId}.turn.off", + new AsyncApiChannel() { + Parameters = new Dictionary + { { "streetlightId", new AsyncApiParameter() { @@ -399,12 +401,12 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, } }, - }, - Subscribe = new AsyncApiOperation() - { - OperationId = "turnOff", - Traits = new List + }, + Subscribe = new AsyncApiOperation() { + OperationId = "turnOff", + Traits = new List + { new AsyncApiOperationTrait() { Reference = new AsyncApiReference() @@ -413,9 +415,9 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Type = ReferenceType.OperationTrait, }, }, - }, - Message = new List - { + }, + Message = new List + { new AsyncApiMessage() { Reference = new AsyncApiReference() @@ -424,15 +426,15 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Type = ReferenceType.Message, }, }, + }, }, - }, - }) - .WithChannel( - "smartylighting.streetlights.1.0.action.{streetlightId}.dim", - new AsyncApiChannel() - { - Parameters = new Dictionary + }) + .WithChannel( + "smartylighting.streetlights.1.0.action.{streetlightId}.dim", + new AsyncApiChannel() { + Parameters = new Dictionary + { { "streetlightId", new AsyncApiParameter() { @@ -443,12 +445,12 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, } }, - }, - Subscribe = new AsyncApiOperation() - { - OperationId = "dimLight", - Traits = new List + }, + Subscribe = new AsyncApiOperation() { + OperationId = "dimLight", + Traits = new List + { new AsyncApiOperationTrait() { Reference = new AsyncApiReference() @@ -457,9 +459,9 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Type = ReferenceType.OperationTrait, }, }, - }, - Message = new List - { + }, + Message = new List + { new AsyncApiMessage() { Reference = new AsyncApiReference() @@ -468,17 +470,17 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Type = ReferenceType.Message, }, }, + }, }, - }, - }) - .WithComponent("lightMeasured", new AsyncApiMessage() - { - Name = "lightMeasured", - Title = "Light measured", - Summary = "Inform about environmental lighting conditions of a particular streetlight.", - ContentType = "application/json", - Traits = new List() + }) + .WithComponent("lightMeasured", new AsyncApiMessage() { + Name = "lightMeasured", + Title = "Light measured", + Summary = "Inform about environmental lighting conditions of a particular streetlight.", + ContentType = "application/json", + Traits = new List() + { new AsyncApiMessageTrait() { Reference = new AsyncApiReference() @@ -487,23 +489,23 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Id = "commonHeaders", }, }, - }, - Payload = new AsyncApiSchema() - { - Reference = new AsyncApiReference() + }, + Payload = new AsyncApiSchema() { - Type = ReferenceType.Schema, - Id = "lightMeasuredPayload", + Reference = new AsyncApiReference() + { + Type = ReferenceType.Schema, + Id = "lightMeasuredPayload", + }, }, - }, - }) - .WithComponent("turnOnOff", new AsyncApiMessage() - { - Name = "turnOnOff", - Title = "Turn on/off", - Summary = "Command a particular streetlight to turn the lights on or off.", - Traits = new List() + }) + .WithComponent("turnOnOff", new AsyncApiMessage() { + Name = "turnOnOff", + Title = "Turn on/off", + Summary = "Command a particular streetlight to turn the lights on or off.", + Traits = new List() + { new AsyncApiMessageTrait() { Reference = new AsyncApiReference() @@ -512,23 +514,23 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Id = "commonHeaders", }, }, - }, - Payload = new AsyncApiSchema() - { - Reference = new AsyncApiReference() + }, + Payload = new AsyncApiSchema() { - Type = ReferenceType.Schema, - Id = "turnOnOffPayload", + Reference = new AsyncApiReference() + { + Type = ReferenceType.Schema, + Id = "turnOnOffPayload", + }, }, - }, - }) - .WithComponent("dimLight", new AsyncApiMessage() - { - Name = "dimLight", - Title = "Dim light", - Summary = "Command a particular streetlight to dim the lights.", - Traits = new List() + }) + .WithComponent("dimLight", new AsyncApiMessage() { + Name = "dimLight", + Title = "Dim light", + Summary = "Command a particular streetlight to dim the lights.", + Traits = new List() + { new AsyncApiMessageTrait() { Reference = new AsyncApiReference() @@ -537,21 +539,21 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Id = "commonHeaders", }, }, - }, - Payload = new AsyncApiSchema() - { - Reference = new AsyncApiReference() + }, + Payload = new AsyncApiSchema() { - Type = ReferenceType.Schema, - Id = "dimLightPayload", + Reference = new AsyncApiReference() + { + Type = ReferenceType.Schema, + Id = "dimLightPayload", + }, }, - }, - }) - .WithComponent("lightMeasuredPayload", new AsyncApiSchema() - { - Type = SchemaType.Object, - Properties = new Dictionary() + }) + .WithComponent("lightMeasuredPayload", new AsyncApiSchema() { + Type = SchemaType.Object, + Properties = new Dictionary() + { { "lumens", new AsyncApiSchema() { @@ -570,13 +572,13 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, } }, - }, - }) - .WithComponent("turnOnOffPayload", new AsyncApiSchema() - { - Type = SchemaType.Object, - Properties = new Dictionary() + }, + }) + .WithComponent("turnOnOffPayload", new AsyncApiSchema() { + Type = SchemaType.Object, + Properties = new Dictionary() + { { "command", new AsyncApiSchema() { @@ -586,7 +588,7 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() new AsyncApiAny("on"), new AsyncApiAny("off"), }, - Description = "Whether to turn on or off the light." + Description = "Whether to turn on or off the light.", } }, { @@ -599,13 +601,13 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, } }, - }, - }) - .WithComponent("dimLightPayload", new AsyncApiSchema() - { - Type = SchemaType.Object, - Properties = new Dictionary() + }, + }) + .WithComponent("dimLightPayload", new AsyncApiSchema() { + Type = SchemaType.Object, + Properties = new Dictionary() + { { "percentage", new AsyncApiSchema() { @@ -625,40 +627,39 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, } }, - }, - }) - .WithComponent("sentAt", new AsyncApiSchema() - { - Type = SchemaType.String, - Format = "date-time", - Description = "Date and time when the message was sent.", - - }) - .WithComponent("saslScram", new AsyncApiSecurityScheme - { - Type = SecuritySchemeType.ScramSha256, - Description = "Provide your username and password for SASL/SCRAM authentication", - }) - .WithComponent("certs", new AsyncApiSecurityScheme - { - Type = SecuritySchemeType.X509, - Description = "Download the certificate files from service provider", - }) - .WithComponent("streetlightId", new AsyncApiParameter() - { - Description = "The ID of the streetlight.", - Schema = new AsyncApiSchema() + }, + }) + .WithComponent("sentAt", new AsyncApiSchema() { Type = SchemaType.String, - }, - }) - .WithComponent("commonHeaders", new AsyncApiMessageTrait() - { - Headers = new AsyncApiSchema() + Format = "date-time", + Description = "Date and time when the message was sent.", + }) + .WithComponent("saslScram", new AsyncApiSecurityScheme { - Type = SchemaType.Object, - Properties = new Dictionary() + Type = SecuritySchemeType.ScramSha256, + Description = "Provide your username and password for SASL/SCRAM authentication", + }) + .WithComponent("certs", new AsyncApiSecurityScheme + { + Type = SecuritySchemeType.X509, + Description = "Download the certificate files from service provider", + }) + .WithComponent("streetlightId", new AsyncApiParameter() + { + Description = "The ID of the streetlight.", + Schema = new AsyncApiSchema() + { + Type = SchemaType.String, + }, + }) + .WithComponent("commonHeaders", new AsyncApiMessageTrait() + { + Headers = new AsyncApiSchema() { + Type = SchemaType.Object, + Properties = new Dictionary() + { { "my-app-header", new AsyncApiSchema() { @@ -667,13 +668,13 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Maximum = 100, } }, + }, }, - }, - }) - .WithComponent("kafka", new AsyncApiOperationTrait() - { - Bindings = new AsyncApiBindings() + }) + .WithComponent("kafka", new AsyncApiOperationTrait() { + Bindings = new AsyncApiBindings() + { { "kafka", new KafkaOperationBinding() { @@ -687,9 +688,9 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() }, } }, - }, - }) - .Build(); + }, + }) + .Build(); // Act var actual = asyncApiDocument.SerializeAsYaml(AsyncApiVersion.AsyncApi2_0); @@ -868,7 +869,6 @@ public void SerializeV2_WithFullSpec_Serializes() string authorizationUrl = "https://example.com/authorization"; string requirementString = "requirementItem"; - var document = new AsyncApiDocument() { Id = documentId, @@ -1034,7 +1034,7 @@ public void SerializeV2_WithFullSpec_Serializes() { Summary = exampleSummary, Name = exampleName, - Payload =new AsyncApiAny(new ExtensionClass + Payload = new AsyncApiAny(new ExtensionClass { Key = anyStringValue, OtherKey = anyLongValue, @@ -1137,7 +1137,7 @@ public void Serialize_WithBindingReferences_SerializesDeserializes() var doc = new AsyncApiDocument(); doc.Info = new AsyncApiInfo() { - Description = "test description" + Description = "test description", }; doc.Servers.Add("production", new AsyncApiServer { @@ -1157,7 +1157,8 @@ public void Serialize_WithBindingReferences_SerializesDeserializes() { Channels = new Dictionary() { - { "otherchannel", new AsyncApiChannel() + { + "otherchannel", new AsyncApiChannel() { Publish = new AsyncApiOperation() { @@ -1171,8 +1172,8 @@ public void Serialize_WithBindingReferences_SerializesDeserializes() Id = "bindings", }, }, - } - } + } + }, }, ServerBindings = new Dictionary>() { @@ -1181,10 +1182,10 @@ public void Serialize_WithBindingReferences_SerializesDeserializes() { new PulsarServerBinding() { - Tenant = "staging" + Tenant = "staging", }, } - } + }, }, ChannelBindings = new Dictionary>() { @@ -1193,21 +1194,22 @@ public void Serialize_WithBindingReferences_SerializesDeserializes() { new PulsarChannelBinding() { - Namespace = "users", + Namespace = "users", Persistence = AsyncAPI.Models.Bindings.Pulsar.Persistence.Persistent, - } + }, } - } + }, }, }; - doc.Channels.Add("testChannel", + doc.Channels.Add( + "testChannel", new AsyncApiChannel { Reference = new AsyncApiReference() { Type = ReferenceType.Channel, - Id = "otherchannel" - } + Id = "otherchannel", + }, }); var actual = doc.Serialize(AsyncApiVersion.AsyncApi2_0, AsyncApiFormat.Yaml); @@ -1216,7 +1218,7 @@ public void Serialize_WithBindingReferences_SerializesDeserializes() var reader = new AsyncApiStringReader(settings); var deserialized = reader.Read(actual, out var diagnostic); } - + [Test] public void Serializev2_WithBindings_Serializes() { @@ -1247,7 +1249,7 @@ public void Serializev2_WithBindings_Serializes() var doc = new AsyncApiDocument(); doc.Info = new AsyncApiInfo() { - Description = "test description" + Description = "test description", }; doc.Servers.Add("production", new AsyncApiServer { @@ -1255,7 +1257,8 @@ public void Serializev2_WithBindings_Serializes() Protocol = "pulsar+ssl", Url = "example.com", }); - doc.Channels.Add("testChannel", + doc.Channels.Add( + "testChannel", new AsyncApiChannel { Bindings = new AsyncApiBindings @@ -1295,7 +1298,6 @@ public void Serializev2_WithBindings_Serializes() }, } }, - }, } }, diff --git a/test/LEGO.AsyncAPI.Tests/AsyncApiLicenseTests.cs b/test/LEGO.AsyncAPI.Tests/AsyncApiLicenseTests.cs index bcb25150..44fbad93 100644 --- a/test/LEGO.AsyncAPI.Tests/AsyncApiLicenseTests.cs +++ b/test/LEGO.AsyncAPI.Tests/AsyncApiLicenseTests.cs @@ -56,14 +56,14 @@ public static Stream GenerateStreamFromString(string s) public void LoadLicense_WithJson_Deserializes() { // Arrange - var input = @"{ + var input = @"{ ""name"": ""test"", ""url"": ""https://example.com/license"", ""x-extension"": ""value"" }"; - using (var stream = GenerateStreamFromString(input)) - { + using (var stream = GenerateStreamFromString(input)) + { var diagnostic = new AsyncApiDiagnostic(); var context = new ParsingContext(diagnostic); diff --git a/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs b/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs index 8461aece..40a2ddbb 100644 --- a/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs +++ b/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs @@ -103,10 +103,10 @@ public void Read_WithThrowingExtensionParser_AddsToDiagnostics() Assert.AreEqual("Failed to parse", error.Message); } - [Test] - public void Read_WithBasicPlusContact_Deserializes() - { - var yaml = @"asyncapi: 2.3.0 + [Test] + public void Read_WithBasicPlusContact_Deserializes() + { + var yaml = @"asyncapi: 2.3.0 info: title: test version: 1.0.0 @@ -118,17 +118,17 @@ public void Read_WithBasicPlusContact_Deserializes() workspace: x-eventarchetype: objectchanged "; - var reader = new AsyncApiStringReader(); - var doc = reader.Read(yaml, out var diagnostic); - Assert.AreEqual("support@example.com", doc.Info.Contact.Email); - Assert.AreEqual(new Uri("https://www.example.com/support"), doc.Info.Contact.Url); - Assert.AreEqual("API Support", doc.Info.Contact.Name); - } + var reader = new AsyncApiStringReader(); + var doc = reader.Read(yaml, out var diagnostic); + Assert.AreEqual("support@example.com", doc.Info.Contact.Email); + Assert.AreEqual(new Uri("https://www.example.com/support"), doc.Info.Contact.Url); + Assert.AreEqual("API Support", doc.Info.Contact.Name); + } - [Test] - public void Read_WithBasicPlusExternalDocs_Deserializes() - { - var yaml = @"asyncapi: 2.3.0 + [Test] + public void Read_WithBasicPlusExternalDocs_Deserializes() + { + var yaml = @"asyncapi: 2.3.0 info: title: test version: 1.0.0 @@ -148,17 +148,17 @@ public void Read_WithBasicPlusExternalDocs_Deserializes() description: Find more info here url: https://example.com "; - var reader = new AsyncApiStringReader(); - var doc = reader.Read(yaml, out var diagnostic); - var message = doc.Channels["workspace"].Publish.Message; - Assert.AreEqual(new Uri("https://example.com"), message.First().ExternalDocs.Url); - Assert.AreEqual("Find more info here", message.First().ExternalDocs.Description); - } + var reader = new AsyncApiStringReader(); + var doc = reader.Read(yaml, out var diagnostic); + var message = doc.Channels["workspace"].Publish.Message; + Assert.AreEqual(new Uri("https://example.com"), message.First().ExternalDocs.Url); + Assert.AreEqual("Find more info here", message.First().ExternalDocs.Description); + } - [Test] - public void Read_WithBasicPlusTag_Deserializes() - { - var yaml = @"asyncapi: 2.3.0 + [Test] + public void Read_WithBasicPlusTag_Deserializes() + { + var yaml = @"asyncapi: 2.3.0 info: title: test version: 1.0.0 @@ -169,17 +169,17 @@ public void Read_WithBasicPlusTag_Deserializes() - name: user description: User-related messages "; - var reader = new AsyncApiStringReader(); - var doc = reader.Read(yaml, out var diagnostic); - var tag = doc.Tags.First(); - Assert.AreEqual("user", tag.Name); - Assert.AreEqual("User-related messages", tag.Description); - } + var reader = new AsyncApiStringReader(); + var doc = reader.Read(yaml, out var diagnostic); + var tag = doc.Tags.First(); + Assert.AreEqual("user", tag.Name); + Assert.AreEqual("User-related messages", tag.Description); + } - [Test] - public void Read_WithBasicPlusServerDeserializes() - { - var yaml = @"asyncapi: 2.3.0 + [Test] + public void Read_WithBasicPlusServerDeserializes() + { + var yaml = @"asyncapi: 2.3.0 info: title: test version: 1.0.0 @@ -192,19 +192,19 @@ public void Read_WithBasicPlusServerDeserializes() protocol: pulsar+ssl description: Pulsar broker "; - var reader = new AsyncApiStringReader(); - var doc = reader.Read(yaml, out var diagnostic); - var server = doc.Servers.First(); - Assert.AreEqual("production", server.Key); - Assert.AreEqual("pulsar+ssl://prod.events.managed.io:1234", server.Value.Url); - Assert.AreEqual("pulsar+ssl", server.Value.Protocol); - Assert.AreEqual("Pulsar broker", server.Value.Description); - } + var reader = new AsyncApiStringReader(); + var doc = reader.Read(yaml, out var diagnostic); + var server = doc.Servers.First(); + Assert.AreEqual("production", server.Key); + Assert.AreEqual("pulsar+ssl://prod.events.managed.io:1234", server.Value.Url); + Assert.AreEqual("pulsar+ssl", server.Value.Protocol); + Assert.AreEqual("Pulsar broker", server.Value.Description); + } - [Test] - public void Read_WithBasicPlusServerVariablesDeserializes() - { - var yaml = @"asyncapi: 2.3.0 + [Test] + public void Read_WithBasicPlusServerVariablesDeserializes() + { + var yaml = @"asyncapi: 2.3.0 info: title: test version: 1.0.0 @@ -224,19 +224,19 @@ public void Read_WithBasicPlusServerVariablesDeserializes() - '1883' - '8883' "; - var reader = new AsyncApiStringReader(); - var doc = reader.Read(yaml, out var diagnostic); - var server = doc.Servers.First(); - var variable = server.Value.Variables.First(); - Assert.AreEqual("production", server.Key); - Assert.AreEqual("port", variable.Key); - Assert.AreEqual("Secure connection (TLS) is available through port 8883.", variable.Value.Description); - } + var reader = new AsyncApiStringReader(); + var doc = reader.Read(yaml, out var diagnostic); + var server = doc.Servers.First(); + var variable = server.Value.Variables.First(); + Assert.AreEqual("production", server.Key); + Assert.AreEqual("port", variable.Key); + Assert.AreEqual("Secure connection (TLS) is available through port 8883.", variable.Value.Description); + } - [Test] - public void Read_WithBasicPlusCorrelationIDDeserializes() - { - var yaml = @"asyncapi: 2.3.0 + [Test] + public void Read_WithBasicPlusCorrelationIDDeserializes() + { + var yaml = @"asyncapi: 2.3.0 info: title: test version: 1.0.0 @@ -256,12 +256,12 @@ public void Read_WithBasicPlusCorrelationIDDeserializes() description: Default Correlation ID location: $message.header#/correlationId "; - var reader = new AsyncApiStringReader(); - var doc = reader.Read(yaml, out var diagnostic); - var message = doc.Channels["workspace"].Publish.Message; - Assert.AreEqual("Default Correlation ID", message.First().CorrelationId.Description); - Assert.AreEqual("$message.header#/correlationId", message.First().CorrelationId.Location); - } + var reader = new AsyncApiStringReader(); + var doc = reader.Read(yaml, out var diagnostic); + var message = doc.Channels["workspace"].Publish.Message; + Assert.AreEqual("Default Correlation ID", message.First().CorrelationId.Description); + Assert.AreEqual("$message.header#/correlationId", message.First().CorrelationId.Location); + } [Test] public void Read_WithOneOfMessage_Reads() @@ -295,9 +295,9 @@ public void Read_WithOneOfMessage_Reads() } [Test] - public void Read_WithBasicPlusSecuritySchemeDeserializes() - { - var yaml = @"asyncapi: 2.3.0 + public void Read_WithBasicPlusSecuritySchemeDeserializes() + { + var yaml = @"asyncapi: 2.3.0 info: title: test version: 1.0.0 @@ -318,18 +318,18 @@ public void Read_WithBasicPlusSecuritySchemeDeserializes() type: scramSha256 description: Provide your username and password for SASL/SCRAM authentication "; - var reader = new AsyncApiStringReader(); - var doc = reader.Read(yaml, out var diagnostic); - var scheme = doc.Components.SecuritySchemes.First(); - Assert.AreEqual("saslScram", scheme.Key); - Assert.AreEqual(SecuritySchemeType.ScramSha256, scheme.Value.Type); - Assert.AreEqual("Provide your username and password for SASL/SCRAM authentication", scheme.Value.Description); - } + var reader = new AsyncApiStringReader(); + var doc = reader.Read(yaml, out var diagnostic); + var scheme = doc.Components.SecuritySchemes.First(); + Assert.AreEqual("saslScram", scheme.Key); + Assert.AreEqual(SecuritySchemeType.ScramSha256, scheme.Value.Type); + Assert.AreEqual("Provide your username and password for SASL/SCRAM authentication", scheme.Value.Description); + } - [Test] - public void Read_WithBasicPlusOAuthFlowDeserializes() - { - var yaml = @"asyncapi: 2.3.0 + [Test] + public void Read_WithBasicPlusOAuthFlowDeserializes() + { + var yaml = @"asyncapi: 2.3.0 info: title: test version: 1.0.0 @@ -347,16 +347,16 @@ public void Read_WithBasicPlusOAuthFlowDeserializes() write:pets: modify pets in your account read:pets: read your pets "; - var reader = new AsyncApiStringReader(); - var doc = reader.Read(yaml, out var diagnostic); - var scheme = doc.Components.SecuritySchemes.First(); - var flow = scheme.Value.Flows; - Assert.AreEqual("oauth2", scheme.Key); - Assert.AreEqual(SecuritySchemeType.OAuth2, scheme.Value.Type); - Assert.AreEqual(new Uri("https://example.com/api/oauth/dialog"), flow.Implicit.AuthorizationUrl); - Assert.IsTrue(flow.Implicit.Scopes.ContainsKey("write:pets")); - Assert.IsTrue(flow.Implicit.Scopes.ContainsKey("read:pets")); - } + var reader = new AsyncApiStringReader(); + var doc = reader.Read(yaml, out var diagnostic); + var scheme = doc.Components.SecuritySchemes.First(); + var flow = scheme.Value.Flows; + Assert.AreEqual("oauth2", scheme.Key); + Assert.AreEqual(SecuritySchemeType.OAuth2, scheme.Value.Type); + Assert.AreEqual(new Uri("https://example.com/api/oauth/dialog"), flow.Implicit.AuthorizationUrl); + Assert.IsTrue(flow.Implicit.Scopes.ContainsKey("write:pets")); + Assert.IsTrue(flow.Implicit.Scopes.ContainsKey("read:pets")); + } [Test] public void Read_WithServerReference_ResolvesReference() @@ -573,6 +573,6 @@ public void Read_WithBasicPlusSecurityRequirementsDeserializes() Assert.AreEqual(SecuritySchemeType.OAuth2, requirement.Key.Type); Assert.IsTrue(requirement.Value.Contains("write:pets")); Assert.IsTrue(requirement.Value.Contains("read:pets")); - } + } } } diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/AMQP/AMQPBindings_Should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/AMQP/AMQPBindings_Should.cs index 09317d0c..e9178311 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/AMQP/AMQPBindings_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/AMQP/AMQPBindings_Should.cs @@ -162,7 +162,7 @@ public void AMQPOperationBinding_WithFilledObject_SerializesAndDeserializes() Bcc = new List { "external.audit" }, Timestamp = true, Ack = false, - });; + }); ; // Act var actual = operation.SerializeAsYaml(AsyncApiVersion.AsyncApi2_0); diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/CustomBinding_Should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/CustomBinding_Should.cs index 461bbf79..5dafed7b 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/CustomBinding_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/CustomBinding_Should.cs @@ -18,7 +18,7 @@ public class NestedConfiguration : IAsyncApiExtensible public IDictionary Extensions { get; set; } = new Dictionary(); - public static FixedFieldMap FixedFieldMap = new () + public static FixedFieldMap FixedFieldMap = new() { { "name", (a, n) => { a.Name = n.GetScalarValue(); } }, }; @@ -84,10 +84,10 @@ public void CustomBinding_SerializesDeserializes() channel.Bindings.Add(new MyBinding { Custom = "someValue", - Any = new AsyncApiObject() + Any = new AsyncApiAny(new Dictionary() { - { "anyKeyName", new AsyncApiAny("anyValue") }, - }, + { "anyKeyName", "anyValue" }, + }), BindingVersion = "0.1.0", NestedConfiguration = new NestedConfiguration() { diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/Sns/SnsBindings_Should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/Sns/SnsBindings_Should.cs index dbca5966..385ccfd5 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/Sns/SnsBindings_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/Sns/SnsBindings_Should.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Tests.Bindings.Sns { using System.Collections.Generic; @@ -59,10 +61,10 @@ public void SnsChannelBinding_WithFilledObject_SerializesAndDeserializes() { { "x-orderingExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "orderingXPropertyName", new AsyncApiAny("orderingXPropertyValue") }, - } + { "orderingXPropertyName", "orderingXPropertyValue" }, + }) }, }, }, @@ -74,29 +76,29 @@ public void SnsChannelBinding_WithFilledObject_SerializesAndDeserializes() { Effect = Effect.Deny, Principal = new StringOrStringList(new AsyncApiAny("arn:aws:iam::123456789012:user/alex.wichmann")), - Action = new StringOrStringList(new AsyncApiArray() + Action = new StringOrStringList(new AsyncApiAny(new List() { - new AsyncApiAny("sns:Publish"), - new AsyncApiAny("sns:Delete") - }), + "sns:Publish", + "sns:Delete", + })), }, new Statement() { Effect = Effect.Allow, - Principal = new StringOrStringList(new AsyncApiArray() + Principal = new StringOrStringList(new AsyncApiAny(new List() { - new AsyncApiAny("arn:aws:iam::123456789012:user/alex.wichmann"), - new AsyncApiAny("arn:aws:iam::123456789012:user/dec.kolakowski") - }), + "arn:aws:iam::123456789012:user/alex.wichmann", + "arn:aws:iam::123456789012:user/dec.kolakowski", + })), Action = new StringOrStringList(new AsyncApiAny("sns:Create")), Extensions = new Dictionary() { { "x-statementExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "statementXPropertyName", new AsyncApiAny("statementXPropertyValue") }, - } + { "statementXPropertyName", "statementXPropertyValue" }, + }) }, }, }, @@ -105,10 +107,10 @@ public void SnsChannelBinding_WithFilledObject_SerializesAndDeserializes() { { "x-policyExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "policyXPropertyName", new AsyncApiAny("policyXPropertyValue") }, - } + { "policyXPropertyName", "policyXPropertyValue" }, + }) }, }, }, @@ -121,10 +123,10 @@ public void SnsChannelBinding_WithFilledObject_SerializesAndDeserializes() { { "x-bindingExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "bindingXPropertyName", new AsyncApiAny("bindingXPropertyValue") }, - } + { "bindingXPropertyName", "bindingXPropertyValue" }, + }) }, }, }); @@ -222,10 +224,10 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-identifierExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "identifierXPropertyName", new AsyncApiAny("identifierXPropertyValue") }, - } + { "identifierXPropertyName", "identifierXPropertyValue" }, + }) }, }, }, @@ -241,41 +243,41 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-identifierExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "identifierXPropertyName", new AsyncApiAny("identifierXPropertyValue") }, - } + { "identifierXPropertyName", "identifierXPropertyValue" }, + }) }, }, }, - FilterPolicy = new AsyncApiObject() - { - { "store", new AsyncApiArray() { new AsyncApiAny("asyncapi_corp") } }, - { "contact", new AsyncApiAny("dec.kolakowski") }, + FilterPolicy = new AsyncApiAny(new Dictionary() + { + { "store", new List() { "asyncapi_corp" } }, + { "contact", "dec.kolakowski" }, { - "event", new AsyncApiArray() + "event", new List>() { - new AsyncApiObject() + new Dictionary() { - { "anything-but", new AsyncApiAny("order_cancelled") }, + { "anything-but", "order_cancelled" }, }, } }, { - "order_key", new AsyncApiObject() + "order_key", new Dictionary() { - { "transient", new AsyncApiAny("by_area") }, + { "transient", "by_area" }, } }, { - "customer_interests", new AsyncApiArray() + "customer_interests", new List() { - new AsyncApiAny("rugby"), - new AsyncApiAny("football"), - new AsyncApiAny("baseball"), + "rugby", + "football", + "baseball", } }, - }, + }), FilterPolicyScope = FilterPolicyScope.MessageAttributes, RawMessageDelivery = false, RedrivePolicy = new RedrivePolicy() @@ -287,10 +289,10 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-identifierExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "identifierXPropertyName", new AsyncApiAny("identifierXPropertyValue") }, - } + { "identifierXPropertyName", "identifierXPropertyValue" }, + }) }, }, }, @@ -299,10 +301,10 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-redrivePolicyExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "redrivePolicyXPropertyName", new AsyncApiAny("redrivePolicyXPropertyValue") }, - } + { "redrivePolicyXPropertyName", "redrivePolicyXPropertyValue" }, + }) }, }, }, @@ -320,10 +322,10 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-deliveryPolicyExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "deliveryPolicyXPropertyName", new AsyncApiAny("deliveryPolicyXPropertyValue") }, - } + { "deliveryPolicyXPropertyName", "deliveryPolicyXPropertyValue" }, + }) }, }, }, @@ -331,10 +333,10 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-consumerExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "consumerXPropertyName", new AsyncApiAny("consumerXPropertyValue") }, - } + { "consumerXPropertyName", "consumerXPropertyValue" }, + }) }, }, }, @@ -353,10 +355,10 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-deliveryPolicyExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "deliveryPolicyXPropertyName", new AsyncApiAny("deliveryPolicyXPropertyValue") }, - } + { "deliveryPolicyXPropertyName", "deliveryPolicyXPropertyValue" }, + }) }, }, }, @@ -364,10 +366,10 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-bindingExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "bindingXPropertyName", new AsyncApiAny("bindingXPropertyValue") }, - } + { "bindingXPropertyName", "bindingXPropertyValue" }, + }) }, }, }); @@ -391,6 +393,7 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes() var expectedSnsBinding = (SnsOperationBinding)operation.Bindings.Values.First(); expectedSnsBinding.Should().BeEquivalentTo((SnsOperationBinding)binding.Bindings.Values.First(), options => options.IgnoringCyclicReferences()); } + class ExtensionClass { public string bindingXPropertyName { get; set; } diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs index d72177ce..63eeff51 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Tests.Bindings.Sqs { using System.Collections.Generic; @@ -94,10 +96,10 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() { { "x-identifierExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary { - { "identifierXPropertyName", new AsyncApiAny("identifierXPropertyValue") }, - } + { "identifierXPropertyName", "identifierXPropertyValue" }, + }) }, }, }, @@ -106,10 +108,10 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() { { "x-redrivePolicyExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary { - { "redrivePolicyXPropertyName", new AsyncApiAny("redrivePolicyXPropertyValue") }, - } + { "redrivePolicyXPropertyName", "redrivePolicyXPropertyValue" }, + }) }, }, }, @@ -121,30 +123,30 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() { Effect = Effect.Deny, Principal = new StringOrStringList(new AsyncApiAny("arn:aws:iam::123456789012:user/alex.wichmann")), - Action = new StringOrStringList(new AsyncApiArray() + Action = new StringOrStringList(new AsyncApiAny(new List { - new AsyncApiAny("sqs:SendMessage"), - new AsyncApiAny("sqs:ReceiveMessage") - }), + "sqs:SendMessage", + "sqs:ReceiveMessage", + })), Extensions = new Dictionary() { { "x-statementExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary { - { "statementXPropertyName", new AsyncApiAny("statementXPropertyValue") }, - } + { "statementXPropertyName", "statementXPropertyValue" }, + }) }, }, }, new Statement() { Effect = Effect.Allow, - Principal = new StringOrStringList(new AsyncApiArray + Principal = new StringOrStringList(new AsyncApiAny(new List { - new AsyncApiAny("arn:aws:iam::123456789012:user/alex.wichmann"), - new AsyncApiAny("arn:aws:iam::123456789012:user/dec.kolakowski") - }), + "arn:aws:iam::123456789012:user/alex.wichmann", + "arn:aws:iam::123456789012:user/dec.kolakowski", + })), Action = new StringOrStringList(new AsyncApiAny("sqs:CreateQueue")), }, }, @@ -152,10 +154,10 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() { { "x-policyExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary { - { "policyXPropertyName", new AsyncApiAny("policyXPropertyValue") }, - } + { "policyXPropertyName", "policyXPropertyValue" }, + }) }, }, }, @@ -168,10 +170,10 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() { { "x-queueExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary { - { "queueXPropertyName", new AsyncApiAny("queueXPropertyValue") }, - } + { "queueXPropertyName", "queueXPropertyValue" }, + }) }, }, }, @@ -191,10 +193,10 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() { Effect = Effect.Allow, Principal = new StringOrStringList(new AsyncApiAny("arn:aws:iam::123456789012:user/alex.wichmann")), - Action = new StringOrStringList(new AsyncApiArray() + Action = new StringOrStringList(new AsyncApiAny(new List { - new AsyncApiAny("sqs:*"), - }), + "sqs:*", + })), }, }, }, @@ -202,10 +204,10 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() Extensions = new Dictionary() { { - "x-internalObject", new AsyncApiObject() + "x-internalObject", new AsyncApiAny(new Dictionary { - { "myExtensionPropertyName", new AsyncApiAny("myExtensionPropertyValue") }, - } + { "myExtensionPropertyName", "myExtensionPropertyValue" }, + }) }, }, }); @@ -219,8 +221,7 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() var settings = new AsyncApiReaderSettings(); settings.Bindings = BindingsCollection.Sqs; var binding = - new AsyncApiStringReader(settings).ReadFragment(actual, AsyncApiVersion.AsyncApi2_0, - out _); + new AsyncApiStringReader(settings).ReadFragment(actual, AsyncApiVersion.AsyncApi2_0, out _); // Assert Assert.AreEqual(expected, actual); @@ -309,10 +310,10 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-identifierExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary { - { "identifierXPropertyName", new AsyncApiAny("identifierXPropertyValue") }, - } + { "identifierXPropertyName", "identifierXPropertyValue" }, + }) }, }, }, @@ -321,10 +322,10 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-redrivePolicyExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary { - { "redrivePolicyXPropertyName", new AsyncApiAny("redrivePolicyXPropertyValue") }, - } + { "redrivePolicyXPropertyName", "redrivePolicyXPropertyValue" }, + }) }, }, }, @@ -336,41 +337,41 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() { Effect = Effect.Deny, Principal = new StringOrStringList(new AsyncApiAny("arn:aws:iam::123456789012:user/alex.wichmann")), - Action = new StringOrStringList(new AsyncApiArray() + Action = new StringOrStringList(new AsyncApiAny(new List() { - new AsyncApiAny("sqs:SendMessage"), - new AsyncApiAny("sqs:ReceiveMessage") - }), + "sqs:SendMessage", + "sqs:ReceiveMessage", + })), Extensions = new Dictionary() { { "x-statementExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "statementXPropertyName", new AsyncApiAny("statementXPropertyValue") }, - } + { "statementXPropertyName", "statementXPropertyValue" }, + }) }, }, }, new Statement() { Effect = Effect.Allow, - Principal = new StringOrStringList(new AsyncApiArray + Principal = new StringOrStringList(new AsyncApiAny(new List { - new AsyncApiAny("arn:aws:iam::123456789012:user/alex.wichmann"), - new AsyncApiAny("arn:aws:iam::123456789012:user/dec.kolakowski"), - }), - Action = new StringOrStringList(new AsyncApiAny("sqs:CreateQueue")) + "arn:aws:iam::123456789012:user/alex.wichmann", + "arn:aws:iam::123456789012:user/dec.kolakowski", + })), + Action = new StringOrStringList(new AsyncApiAny("sqs:CreateQueue")), }, }, Extensions = new Dictionary() { { "x-policyExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary { - { "policyXPropertyName", new AsyncApiAny("policyXPropertyValue") }, - } + { "policyXPropertyName", "policyXPropertyValue" }, + }) }, }, }, @@ -383,10 +384,10 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-queueExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "queueXPropertyName", new AsyncApiAny("queueXPropertyValue") }, - } + { "queueXPropertyName", "queueXPropertyValue" }, + }) }, }, }, @@ -406,10 +407,10 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() { Effect = Effect.Allow, Principal = new StringOrStringList(new AsyncApiAny("arn:aws:iam::123456789012:user/alex.wichmann")), - Action = new StringOrStringList(new AsyncApiArray + Action = new StringOrStringList(new AsyncApiAny(new List { - new AsyncApiAny("sqs:*") - }) + "sqs:*", + })), }, }, }, @@ -417,10 +418,10 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() { { "x-queueExtension", - new AsyncApiObject() + new AsyncApiAny(new Dictionary() { - { "queueXPropertyName", new AsyncApiAny("queueXPropertyValue") }, - } + { "queueXPropertyName", "queueXPropertyValue" }, + }) }, }, }, @@ -428,10 +429,10 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() Extensions = new Dictionary() { { - "x-internalObject", new AsyncApiObject() + "x-internalObject", new AsyncApiAny(new Dictionary() { - { "myExtensionPropertyName", new AsyncApiAny("myExtensionPropertyValue") }, - } + { "myExtensionPropertyName", "myExtensionPropertyValue" }, + }) }, }, }); diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/StringOrStringList_Should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/StringOrStringList_Should.cs index 5e2780e7..21b64f5e 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/StringOrStringList_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/StringOrStringList_Should.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Tests.Bindings { using System; @@ -13,23 +15,21 @@ namespace LEGO.AsyncAPI.Tests.Bindings public class StringOrStringList_Should { - [Test] public void StringOrStringList_IsInitialised_WhenPassedStringOrStringList() { // Arrange var stringValue = new StringOrStringList(new AsyncApiAny("AsyncApi")); var listValue = new StringOrStringList( - new AsyncApiArray() + new AsyncApiAny(new List() { - new AsyncApiAny("Async"), - new AsyncApiAny("Api"), - }); + "Async", + "Api", + })); // Assert stringValue.Value.GetValue().Should().Be("AsyncApi"); - ((AsyncApiArray)listValue.Value) - .Select(s => s.GetValue()) + listValue.Value.GetValue>() .Should().BeEquivalentTo(new List() { "Async", "Api" }); } @@ -48,12 +48,12 @@ public void StringOrStringList_ThrowsArgumentException_WhenIntialisedWithListOfN { // Assert var ex = Assert.Throws(() => new StringOrStringList( - new AsyncApiArray() + new AsyncApiAny(new List() { - new AsyncApiAny("x"), - new AsyncApiAny(1), - new AsyncApiAny("y"), - })); + "x", + 1, + "y", + }))); // Assert ex.Message.Should().Be("StringOrStringList value should only contain string items."); @@ -103,12 +103,12 @@ public void StringOrStringList_WhenValueIsStringList_SerializesDeserializes() var channel = new AsyncApiChannel(); channel.Bindings.Add(new StringOrStringListTestBinding { - TestProperty = new StringOrStringList(new AsyncApiArray + TestProperty = new StringOrStringList(new AsyncApiAny(new List { - new AsyncApiAny("someValue01"), - new AsyncApiAny("someValue02"), - new AsyncApiAny("someValue03"), - }), + "someValue01", + "someValue02", + "someValue03", + })), }); // Act @@ -141,7 +141,7 @@ public override void SerializeProperties(IAsyncApiWriter writer) writer.WriteEndObject(); } - protected override FixedFieldMap FixedFieldMap => new () + protected override FixedFieldMap FixedFieldMap => new() { { "testProperty", (a, n) => { a.TestProperty = new StringOrStringList(n.CreateAny()); } }, }; diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs index 598ef31f..6c93e483 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs @@ -1,4 +1,6 @@ -using LEGO.AsyncAPI.Models; +// Copyright (c) The LEGO Group. All rights reserved. + +using LEGO.AsyncAPI.Models; using NUnit.Framework; using System; using System.Collections.Generic; @@ -6,7 +8,6 @@ namespace LEGO.AsyncAPI.Tests { - public class AsyncApiAnyTests { [Test] @@ -19,8 +20,8 @@ public void GetValue_ReturnsCorrectConversions() var c = new AsyncApiAny(1.1); var d = new AsyncApiAny(true); var e = new AsyncApiAny(new MyType("test")); - var f = new AsyncApiAny(new List() { "test", "test2"}); - var g = new AsyncApiAny(new List() { "test", "test2"}.AsEnumerable()); + var f = new AsyncApiAny(new List() { "test", "test2" }); + var g = new AsyncApiAny(new List() { "test", "test2" }.AsEnumerable()); var h = new AsyncApiAny(new List() { new MyType("test") }); var i = new AsyncApiAny(new Dictionary() { { "t", 2 } }); var j = new AsyncApiAny(new Dictionary() { { "t", new MyType("test") } }); diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiChannel_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiChannel_Should.cs index 05f91943..18e6b4fd 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiChannel_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiChannel_Should.cs @@ -96,7 +96,6 @@ public void AsyncApiChannel_WithKafkaBinding_Serializes() Replicas = 2, } }, - }, }; diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs index 0849aa85..67156b1d 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs @@ -15,12 +15,12 @@ namespace LEGO.AsyncAPI.Tests.Models internal class AsyncApiMessage_Should { - [Test] - public void AsyncApiMessage_WithNoType_DeserializesToDefault() - { - // Arrange - var expected = - @"{ + [Test] + public void AsyncApiMessage_WithNoType_DeserializesToDefault() + { + // Arrange + var expected = + @"{ ""payload"": { ""type"": ""object"", ""properties"": { @@ -34,19 +34,19 @@ public void AsyncApiMessage_WithNoType_DeserializesToDefault() } }"; - // Act - var message = new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out var diagnostic); + // Act + var message = new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out var diagnostic); - // Assert - diagnostic.Errors.Should().BeEmpty(); - message.Payload.Properties.First().Value.Enum.Should().HaveCount(2); - } + // Assert + diagnostic.Errors.Should().BeEmpty(); + message.Payload.Properties.First().Value.Enum.Should().HaveCount(2); + } - [Test] - public void AsyncApiMessage_WithNoSchemaFormat_DeserializesToDefault() - { - // Arrange - var expected = + [Test] + public void AsyncApiMessage_WithNoSchemaFormat_DeserializesToDefault() + { + // Arrange + var expected = @"payload: properties: propertyA: @@ -54,20 +54,20 @@ public void AsyncApiMessage_WithNoSchemaFormat_DeserializesToDefault() - 'null' - string"; - // Act - var message = new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out var diagnostic); + // Act + var message = new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out var diagnostic); - // Assert - diagnostic.Errors.Should().BeEmpty(); - message.SchemaFormat.Should().BeNull(); - } + // Assert + diagnostic.Errors.Should().BeEmpty(); + message.SchemaFormat.Should().BeNull(); + } - [Test] - public void AsyncApiMessage_WithUnsupportedSchemaFormat_DeserializesWithError() - { - // Arrange - var expected = - @"payload: + [Test] + public void AsyncApiMessage_WithUnsupportedSchemaFormat_DeserializesWithError() + { + // Arrange + var expected = +@"payload: properties: propertyA: type: @@ -75,30 +75,30 @@ public void AsyncApiMessage_WithUnsupportedSchemaFormat_DeserializesWithError() - string schemaFormat: application/vnd.apache.avro;version=1.9.0"; - // Act - new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out var diagnostic); + // Act + new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out var diagnostic); - // Assert - diagnostic.Errors.Should().HaveCount(1); - diagnostic.Errors.First().Message.Should().StartWith("'application/vnd.apache.avro;version=1.9.0' is not a supported format"); - } + // Assert + diagnostic.Errors.Should().HaveCount(1); + diagnostic.Errors.First().Message.Should().StartWith("'application/vnd.apache.avro;version=1.9.0' is not a supported format"); + } - [Test] - public void AsyncApiMessage_WithNoSchemaFormat_DoesNotSerializeSchemaFormat() - { - // Arrange - var expected = - @"payload: + [Test] + public void AsyncApiMessage_WithNoSchemaFormat_DoesNotSerializeSchemaFormat() + { + // Arrange + var expected = +@"payload: properties: propertyA: type: - 'null' - string"; - var message = new AsyncApiMessage(); - message.Payload = new AsyncApiSchema() - { - Properties = new Dictionary() + var message = new AsyncApiMessage(); + message.Payload = new AsyncApiSchema() + { + Properties = new Dictionary() { { "propertyA", new AsyncApiSchema() @@ -107,27 +107,27 @@ public void AsyncApiMessage_WithNoSchemaFormat_DoesNotSerializeSchemaFormat() } }, }, - }; + }; - // Act - var actual = message.SerializeAsYaml(AsyncApiVersion.AsyncApi2_0); + // Act + var actual = message.SerializeAsYaml(AsyncApiVersion.AsyncApi2_0); - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual = actual.MakeLineBreaksEnvironmentNeutral(); + expected = expected.MakeLineBreaksEnvironmentNeutral(); - var deserializedMessage = new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out _); + var deserializedMessage = new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out _); - // Assert - Assert.AreEqual(expected, actual); - message.Should().BeEquivalentTo(deserializedMessage); - } + // Assert + Assert.AreEqual(expected, actual); + message.Should().BeEquivalentTo(deserializedMessage); + } - [Test] - public void AsyncApiMessage_WithSchemaFormat_Serializes() - { - // Arrange - var expected = - @"payload: + [Test] + public void AsyncApiMessage_WithSchemaFormat_Serializes() + { + // Arrange + var expected = +@"payload: properties: propertyA: type: @@ -135,11 +135,11 @@ public void AsyncApiMessage_WithSchemaFormat_Serializes() - string schemaFormat: application/vnd.aai.asyncapi+json;version=2.6.0"; - var message = new AsyncApiMessage(); - message.SchemaFormat = "application/vnd.aai.asyncapi+json;version=2.6.0"; - message.Payload = new AsyncApiSchema() - { - Properties = new Dictionary() + var message = new AsyncApiMessage(); + message.SchemaFormat = "application/vnd.aai.asyncapi+json;version=2.6.0"; + message.Payload = new AsyncApiSchema() + { + Properties = new Dictionary() { { "propertyA", new AsyncApiSchema() @@ -148,20 +148,20 @@ public void AsyncApiMessage_WithSchemaFormat_Serializes() } }, }, - }; + }; - // Act - var actual = message.SerializeAsYaml(AsyncApiVersion.AsyncApi2_0); + // Act + var actual = message.SerializeAsYaml(AsyncApiVersion.AsyncApi2_0); - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual = actual.MakeLineBreaksEnvironmentNeutral(); + expected = expected.MakeLineBreaksEnvironmentNeutral(); - var deserializedMessage = new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out _); + var deserializedMessage = new AsyncApiStringReader().ReadFragment(expected, AsyncApiVersion.AsyncApi2_0, out _); - // Assert - Assert.AreEqual(expected, actual); - message.Should().BeEquivalentTo(deserializedMessage); - } + // Assert + Assert.AreEqual(expected, actual); + message.Should().BeEquivalentTo(deserializedMessage); + } [Test] public void AsyncApiMessage_WithFilledObject_Serializes() @@ -243,10 +243,10 @@ public void AsyncApiMessage_WithFilledObject_Serializes() Description = "HeaderDescription", Examples = new List { - new AsyncApiObject + new AsyncApiAny(new Dictionary { - { "x-correlation-id", new AsyncApiAny("nil") }, - }, + { "x-correlation-id", "nil" }, + }), }, }, Payload = new AsyncApiSchema() @@ -262,7 +262,7 @@ public void AsyncApiMessage_WithFilledObject_Serializes() { "propB", new AsyncApiSchema() { - Type =SchemaType.String, + Type = SchemaType.String, } }, }, @@ -306,11 +306,11 @@ public void AsyncApiMessage_WithFilledObject_Serializes() Description = "SchemaDescription", Examples = new List { - new AsyncApiObject + new AsyncApiAny(new Dictionary { - { "cKey", new AsyncApiAny("c") }, - { "dKey", new AsyncApiAny(1) }, - }, + { "cKey", "c" }, + { "dKey", 1 }, + }), }, }, } @@ -320,11 +320,11 @@ public void AsyncApiMessage_WithFilledObject_Serializes() { new AsyncApiMessageExample { - Payload = new AsyncApiObject() + Payload = new AsyncApiAny(new Dictionary() { - { "PropA", new AsyncApiAny("a") }, - { "PropB", new AsyncApiAny("b") }, - }, + { "PropA", "a" }, + { "PropB", "b" }, + }), }, }, Traits = new List @@ -340,11 +340,11 @@ public void AsyncApiMessage_WithFilledObject_Serializes() Description = "SchemaDescription", Examples = new List { - new AsyncApiObject + new AsyncApiAny(new Dictionary { - { "eKey", new AsyncApiAny("e") }, - { "fKey", new AsyncApiAny(1) }, - }, + { "eKey", "e" }, + { "fKey", 1 }, + }), }, }, Examples = new List @@ -353,11 +353,11 @@ public void AsyncApiMessage_WithFilledObject_Serializes() { Summary = "MessageExampleSummary", Name = "MessageExampleName", - Payload = new AsyncApiObject + Payload = new AsyncApiAny(new Dictionary { - { "gKey", new AsyncApiAny("g") }, - { "hKey", new AsyncApiAny(true) }, - }, + { "gKey", "g" }, + { "hKey", true }, + }), Extensions = new Dictionary { { "x-extension-b", new AsyncApiAny("b") }, diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiReference_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiReference_Should.cs index 273162b3..eeaa4047 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiReference_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiReference_Should.cs @@ -10,7 +10,6 @@ namespace LEGO.AsyncAPI.Tests public class AsyncApiReference_Should { - [Test] public void AsyncApiReference_WithExternalFragmentUriReference_AllowReference() { diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs index 686ed9b6..e7d7725e 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs @@ -263,7 +263,7 @@ public class AsyncApiSchema_Should { ["property6"] = new AsyncApiSchema { - Type = SchemaType.Boolean , + Type = SchemaType.Boolean, }, }, }, diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiServer_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiServer_Should.cs index 880694d6..a503b169 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiServer_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiServer_Should.cs @@ -59,7 +59,7 @@ public void AsyncApiServer_Serializes() } }, }); - server.Tags.Add(new AsyncApiTag { Name = "mytag1", Description ="description of tag1" }); + server.Tags.Add(new AsyncApiTag { Name = "mytag1", Description = "description of tag1" }); server.Bindings.Add(new KafkaServerBinding { SchemaRegistryUrl = "http://example.com", @@ -68,7 +68,7 @@ public void AsyncApiServer_Serializes() // Act var actual = server.SerializeAsYaml(AsyncApiVersion.AsyncApi2_0); - + // Assert actual = actual.MakeLineBreaksEnvironmentNeutral(); expected = expected.MakeLineBreaksEnvironmentNeutral();