From f9229797b85457fdda7b70bd1772a46bcc5834a6 Mon Sep 17 00:00:00 2001 From: VisualBean Date: Tue, 28 Jan 2025 09:26:47 +0100 Subject: [PATCH] message- & operation traits plus minor formatting fixes across the solution --- src/LEGO.AsyncAPI.Bindings/Sns/Condition.cs | 30 ++++---- src/LEGO.AsyncAPI.Bindings/Sns/Principal.cs | 24 +++--- .../Sns/PrincipalObject.cs | 2 + .../Sns/PrincipalStar.cs | 2 + src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs | 1 - src/LEGO.AsyncAPI.Bindings/Sqs/Condition.cs | 30 ++++---- src/LEGO.AsyncAPI.Bindings/Sqs/Principal.cs | 22 +++--- .../Sqs/PrincipalObject.cs | 2 + .../Sqs/PrincipalStar.cs | 2 + src/LEGO.AsyncAPI.Bindings/Sqs/Statement.cs | 1 - .../AsyncApiReaderSettings.cs | 1 - .../Interface/IStreamLoader.cs | 1 - .../AsyncApiRemoteReferenceCollector.cs | 6 +- .../V2/AsyncApiAvroSchemaDeserializer.cs | 2 - .../V2/AsyncApiComponentsDeserializer.cs | 4 +- .../V2/AsyncApiMessageTraitDeserializer.cs | 2 +- .../V2/AsyncApiOperationTraitDeserializer.cs | 2 +- src/LEGO.AsyncAPI.Readers/YamlConverter.cs | 2 +- src/LEGO.AsyncAPI/AsyncApiWorkspace.cs | 2 - .../Models/AsyncApiComponents.cs | 12 +-- src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs | 1 - .../Models/AsyncApiMessageTrait.cs | 54 ++++--------- .../Models/AsyncApiOperationTrait.cs | 40 +++------- src/LEGO.AsyncAPI/Models/AsyncApiReference.cs | 1 - src/LEGO.AsyncAPI/Models/AsyncApiServer.cs | 1 - .../Interfaces/IAsyncApiReferenceable.cs | 2 - .../References/AsyncApiChannelReference.cs | 3 +- .../AsyncApiCorrelationIdReference.cs | 3 +- .../References/AsyncApiMessageReference.cs | 3 +- .../AsyncApiMessageTraitReference.cs | 75 +++++++++++++++++++ .../AsyncApiOperationTraitReference.cs | 61 +++++++++++++++ .../References/AsyncApiParameterReference.cs | 3 +- .../AsyncApiSecuritySchemeReference.cs | 2 + .../References/AsyncApiServerReference.cs | 1 - .../AsyncApiServerVariableReference.cs | 3 +- .../Services/AsyncApiReferenceResolver.cs | 9 +-- src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs | 6 +- .../Validation/Rules/AsyncApiDocumentRules.cs | 2 +- .../AsyncApiDocumentV2Tests.cs | 74 +++--------------- .../AsyncApiReaderTests.cs | 3 +- .../WebSockets/WebSocketBindings_Should.cs | 2 +- .../Models/AsyncApiAnyTests.cs | 10 +-- .../Models/AsyncApiMessage_Should.cs | 2 +- .../Models/AsyncApiSchema_Should.cs | 2 +- .../Validation/ValidationRuleTests.cs | 1 - 45 files changed, 271 insertions(+), 243 deletions(-) create mode 100644 src/LEGO.AsyncAPI/Models/References/AsyncApiMessageTraitReference.cs create mode 100644 src/LEGO.AsyncAPI/Models/References/AsyncApiOperationTraitReference.cs diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/Condition.cs b/src/LEGO.AsyncAPI.Bindings/Sns/Condition.cs index 38b21da9..fca3b30c 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/Condition.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/Condition.cs @@ -39,25 +39,25 @@ public static Condition Parse(ParseNode node) switch (node) { case MapNode mapNode: - { - var conditionValues = new Dictionary>(); - foreach (var conditionNode in mapNode) { - switch (conditionNode.Value) + var conditionValues = new Dictionary>(); + foreach (var conditionNode in mapNode) { - case MapNode conditionValueNode: - conditionValues.Add(conditionNode.Name, new Dictionary(conditionValueNode.Select(x => - new KeyValuePair(x.Name, StringOrStringList.Parse(x.Value))) - .ToDictionary(x => x.Key, x => x.Value))); - break; - default: - throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " + - $"AWS condition values should be one or more key value pairs."); + switch (conditionNode.Value) + { + case MapNode conditionValueNode: + conditionValues.Add(conditionNode.Name, new Dictionary(conditionValueNode.Select(x => + new KeyValuePair(x.Name, StringOrStringList.Parse(x.Value))) + .ToDictionary(x => x.Key, x => x.Value))); + break; + default: + throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " + + $"AWS condition values should be one or more key value pairs."); + } } - } - return new Condition(conditionValues); - } + return new Condition(conditionValues); + } default: throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " + diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/Principal.cs b/src/LEGO.AsyncAPI.Bindings/Sns/Principal.cs index a803f6c2..2d630641 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/Principal.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/Principal.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Bindings.Sns; using System; @@ -28,20 +30,20 @@ public static Principal Parse(ParseNode node) return new PrincipalStar(); case MapNode mapNode: - { - var propertyNode = mapNode.First(); - if (!IsValidPrincipalProperty(propertyNode.Name)) { - throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " + - $"Node should contain a valid AWS principal property name."); - } + var propertyNode = mapNode.First(); + if (!IsValidPrincipalProperty(propertyNode.Name)) + { + throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " + + $"Node should contain a valid AWS principal property name."); + } - var principalValue = new KeyValuePair( - propertyNode.Name, - StringOrStringList.Parse(propertyNode.Value)); + var principalValue = new KeyValuePair( + propertyNode.Name, + StringOrStringList.Parse(propertyNode.Value)); - return new PrincipalObject(principalValue); - } + return new PrincipalObject(principalValue); + } default: throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " + diff --git a/src/LEGO.AsyncAPI.Bindings/Sns/PrincipalObject.cs b/src/LEGO.AsyncAPI.Bindings/Sns/PrincipalObject.cs index 209be8bf..946fa4d6 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/PrincipalObject.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/PrincipalObject.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/PrincipalStar.cs b/src/LEGO.AsyncAPI.Bindings/Sns/PrincipalStar.cs index c885d252..bd0e37bf 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/PrincipalStar.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/PrincipalStar.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/Statement.cs b/src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs index da93cfbf..5a7a248c 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs @@ -4,7 +4,6 @@ namespace LEGO.AsyncAPI.Bindings.Sns using System; using System.Collections.Generic; using LEGO.AsyncAPI.Attributes; - using LEGO.AsyncAPI.Models; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/Condition.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/Condition.cs index 93bdf733..9172f3e3 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/Condition.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/Condition.cs @@ -39,25 +39,25 @@ public static Condition Parse(ParseNode node) switch (node) { case MapNode mapNode: - { - var conditionValues = new Dictionary>(); - foreach (var conditionNode in mapNode) { - switch (conditionNode.Value) + var conditionValues = new Dictionary>(); + foreach (var conditionNode in mapNode) { - case MapNode conditionValueNode: - conditionValues.Add(conditionNode.Name, new Dictionary(conditionValueNode.Select(x => - new KeyValuePair(x.Name, StringOrStringList.Parse(x.Value))) - .ToDictionary(x => x.Key, x => x.Value))); - break; - default: - throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " + - $"AWS condition values should be one or more key value pairs."); + switch (conditionNode.Value) + { + case MapNode conditionValueNode: + conditionValues.Add(conditionNode.Name, new Dictionary(conditionValueNode.Select(x => + new KeyValuePair(x.Name, StringOrStringList.Parse(x.Value))) + .ToDictionary(x => x.Key, x => x.Value))); + break; + default: + throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " + + $"AWS condition values should be one or more key value pairs."); + } } - } - return new Condition(conditionValues); - } + return new Condition(conditionValues); + } default: throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " + diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/Principal.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/Principal.cs index 2821f952..eee2b4fe 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/Principal.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/Principal.cs @@ -30,20 +30,20 @@ public static Principal Parse(ParseNode node) return new PrincipalStar(); case MapNode mapNode: - { - var propertyNode = mapNode.First(); - if (!IsValidPrincipalProperty(propertyNode.Name)) { - throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " + - $"Node should contain a valid AWS principal property name."); - } + var propertyNode = mapNode.First(); + if (!IsValidPrincipalProperty(propertyNode.Name)) + { + throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " + + $"Node should contain a valid AWS principal property name."); + } - var principalValue = new KeyValuePair( - propertyNode.Name, - StringOrStringList.Parse(propertyNode.Value)); + var principalValue = new KeyValuePair( + propertyNode.Name, + StringOrStringList.Parse(propertyNode.Value)); - return new PrincipalObject(principalValue); - } + return new PrincipalObject(principalValue); + } default: throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " + diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalObject.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalObject.cs index 61e6e546..a1613247 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalObject.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalObject.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/PrincipalStar.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalStar.cs index 1705b966..a49b02c6 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalStar.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalStar.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 4a9c5303..0c2873d2 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/Statement.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/Statement.cs @@ -5,7 +5,6 @@ namespace LEGO.AsyncAPI.Bindings.Sqs using System; using System.Collections.Generic; using LEGO.AsyncAPI.Attributes; - using LEGO.AsyncAPI.Models; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs b/src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs index 523e1484..890b83e6 100644 --- a/src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs +++ b/src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs @@ -8,7 +8,6 @@ namespace LEGO.AsyncAPI.Readers using LEGO.AsyncAPI.Models; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Readers.Interface; - using LEGO.AsyncAPI.Readers.Services; using LEGO.AsyncAPI.Validations; public enum ReferenceResolutionSetting diff --git a/src/LEGO.AsyncAPI.Readers/Interface/IStreamLoader.cs b/src/LEGO.AsyncAPI.Readers/Interface/IStreamLoader.cs index 14da05c9..d0daca7c 100644 --- a/src/LEGO.AsyncAPI.Readers/Interface/IStreamLoader.cs +++ b/src/LEGO.AsyncAPI.Readers/Interface/IStreamLoader.cs @@ -4,7 +4,6 @@ namespace LEGO.AsyncAPI.Readers.Interface { using System; using System.IO; - using System.Text.Json.Nodes; using System.Threading.Tasks; public interface IStreamLoader diff --git a/src/LEGO.AsyncAPI.Readers/Services/AsyncApiRemoteReferenceCollector.cs b/src/LEGO.AsyncAPI.Readers/Services/AsyncApiRemoteReferenceCollector.cs index 48c710e1..1d33251e 100644 --- a/src/LEGO.AsyncAPI.Readers/Services/AsyncApiRemoteReferenceCollector.cs +++ b/src/LEGO.AsyncAPI.Readers/Services/AsyncApiRemoteReferenceCollector.cs @@ -14,9 +14,9 @@ internal class AsyncApiRemoteReferenceCollector : AsyncApiVisitorBase public AsyncApiRemoteReferenceCollector( AsyncApiDocument currentDocument) - { - this.currentDocument = currentDocument; - } + { + this.currentDocument = currentDocument; + } /// /// List of all external references collected from AsyncApiDocument. /// diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiAvroSchemaDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiAvroSchemaDeserializer.cs index baae8873..1ac2c611 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiAvroSchemaDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiAvroSchemaDeserializer.cs @@ -2,8 +2,6 @@ namespace LEGO.AsyncAPI.Readers { - using System; - using System.Threading; using LEGO.AsyncAPI.Exceptions; using LEGO.AsyncAPI.Models; using LEGO.AsyncAPI.Models.Avro.LogicalTypes; diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiComponentsDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiComponentsDeserializer.cs index 53124676..7cdba6dd 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiComponentsDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiComponentsDeserializer.cs @@ -17,8 +17,8 @@ internal static partial class AsyncApiV2Deserializer { "securitySchemes", (a, n) => a.SecuritySchemes = n.CreateMap(LoadSecurityScheme) }, { "parameters", (a, n) => a.Parameters = n.CreateMap(LoadParameter) }, { "correlationIds", (a, n) => a.CorrelationIds = n.CreateMap(LoadCorrelationId) }, - { "operationTraits", (a, n) => a.OperationTraits = n.CreateMapWithReference(ReferenceType.OperationTrait, LoadOperationTrait) }, - { "messageTraits", (a, n) => a.MessageTraits = n.CreateMapWithReference(ReferenceType.MessageTrait, LoadMessageTrait) }, + { "operationTraits", (a, n) => a.OperationTraits = n.CreateMap(LoadOperationTrait) }, + { "messageTraits", (a, n) => a.MessageTraits = n.CreateMap(LoadMessageTrait) }, { "serverBindings", (a, n) => a.ServerBindings = n.CreateMapWithReference(ReferenceType.ServerBindings, LoadServerBindings) }, { "channelBindings", (a, n) => a.ChannelBindings = n.CreateMapWithReference(ReferenceType.ChannelBindings, LoadChannelBindings) }, { "operationBindings", (a, n) => a.OperationBindings = n.CreateMapWithReference(ReferenceType.OperationBindings, LoadOperationBindings) }, diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageTraitDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageTraitDeserializer.cs index 0d229e92..40e8a945 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageTraitDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiMessageTraitDeserializer.cs @@ -38,7 +38,7 @@ public static AsyncApiMessageTrait LoadMessageTrait(ParseNode node) if (pointer != null) { - return mapNode.GetReferencedObject(ReferenceType.MessageTrait, pointer); + return new AsyncApiMessageTraitReference(pointer); } var messageTrait = new AsyncApiMessageTrait(); diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationTraitDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationTraitDeserializer.cs index 561456e9..ee503d91 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationTraitDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiOperationTraitDeserializer.cs @@ -31,7 +31,7 @@ public static AsyncApiOperationTrait LoadOperationTrait(ParseNode node) var pointer = mapNode.GetReferencePointer(); if (pointer != null) { - return mapNode.GetReferencedObject(ReferenceType.OperationTrait, pointer); + return new AsyncApiOperationTraitReference(pointer); } var operationTrait = new AsyncApiOperationTrait(); diff --git a/src/LEGO.AsyncAPI.Readers/YamlConverter.cs b/src/LEGO.AsyncAPI.Readers/YamlConverter.cs index 29225f06..942bc28f 100644 --- a/src/LEGO.AsyncAPI.Readers/YamlConverter.cs +++ b/src/LEGO.AsyncAPI.Readers/YamlConverter.cs @@ -58,7 +58,7 @@ private static JsonValue ToJsonValue(this YamlScalarNode yaml, CultureInfo cultu ? JsonValue.Create(d) : bool.TryParse(yaml.Value, out var b) ? JsonValue.Create(b) - : JsonValue.Create(yaml.Value) !; + : JsonValue.Create(yaml.Value)!; case ScalarStyle.SingleQuoted: case ScalarStyle.DoubleQuoted: case ScalarStyle.Literal: diff --git a/src/LEGO.AsyncAPI/AsyncApiWorkspace.cs b/src/LEGO.AsyncAPI/AsyncApiWorkspace.cs index 310ddce6..ea6572e6 100644 --- a/src/LEGO.AsyncAPI/AsyncApiWorkspace.cs +++ b/src/LEGO.AsyncAPI/AsyncApiWorkspace.cs @@ -182,8 +182,6 @@ public T ResolveReference(string location) return default; } - - private Uri ToLocationUrl(string location) { return new(location, UriKind.RelativeOrAbsolute); diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiComponents.cs b/src/LEGO.AsyncAPI/Models/AsyncApiComponents.cs index 9ac21433..dee0bbb0 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiComponents.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiComponents.cs @@ -260,11 +260,9 @@ public void SerializeV2(IAsyncApiWriter writer) this.OperationTraits, (w, key, component) => { - if (component.Reference != null && - component.Reference.Type == ReferenceType.OperationTrait && - component.Reference.FragmentId == key) + if (component is AsyncApiOperationTraitReference reference) { - component.SerializeV2WithoutReference(w); + reference.SerializeV2(w); } else { @@ -278,11 +276,9 @@ public void SerializeV2(IAsyncApiWriter writer) this.MessageTraits, (w, key, component) => { - if (component.Reference != null && - component.Reference.Type == ReferenceType.MessageTrait && - component.Reference.FragmentId == key) + if (component is AsyncApiMessageTraitReference reference) { - component.SerializeV2WithoutReference(w); + reference.SerializeV2(w); } else { diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs b/src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs index 1b66525f..89edf733 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs @@ -6,7 +6,6 @@ namespace LEGO.AsyncAPI.Models using System.Collections.Generic; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; - using LEGO.AsyncAPI.Services; /// /// This is the root document object for the API specification. It combines resource listing and API declaration together into one document. diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiMessageTrait.cs b/src/LEGO.AsyncAPI/Models/AsyncApiMessageTrait.cs index 2d972363..1e62adc0 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiMessageTrait.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiMessageTrait.cs @@ -10,22 +10,22 @@ namespace LEGO.AsyncAPI.Models /// /// Describes a trait that MAY be applied to a Message Object. /// - public class AsyncApiMessageTrait : IAsyncApiExtensible, IAsyncApiReferenceable, IAsyncApiSerializable + public class AsyncApiMessageTrait : IAsyncApiExtensible, IAsyncApiSerializable { /// /// Unique string used to identify the message. The id MUST be unique among all messages described in the API. /// - public string MessageId { get; set; } + public virtual string MessageId { get; set; } /// /// schema definition of the application headers. Schema MUST be of type "object". /// - public AsyncApiJsonSchema Headers { get; set; } + public virtual AsyncApiJsonSchema Headers { get; set; } /// /// definition of the correlation ID used for message tracing or matching. /// - public AsyncApiCorrelationId CorrelationId { get; set; } + public virtual AsyncApiCorrelationId CorrelationId { get; set; } /// /// a string containing the name of the schema format used to define the message payload. @@ -33,78 +33,56 @@ public class AsyncApiMessageTrait : IAsyncApiExtensible, IAsyncApiReferenceable, /// /// If omitted, implementations should parse the payload as a Schema object. /// - public string SchemaFormat { get; set; } + public virtual string SchemaFormat { get; set; } /// /// the content type to use when encoding/decoding a message's payload. /// - public string ContentType { get; set; } + public virtual string ContentType { get; set; } /// /// a machine-friendly name for the message. /// - public string Name { get; set; } + public virtual string Name { get; set; } /// /// a human-friendly title for the message. /// - public string Title { get; set; } + public virtual string Title { get; set; } /// /// a short summary of what the message is about. /// - public string Summary { get; set; } + public virtual string Summary { get; set; } /// /// a verbose explanation of the message. CommonMark syntax can be used for rich text representation. /// - public string Description { get; set; } + public virtual string Description { get; set; } /// /// a list of tags for API documentation control. Tags can be used for logical grouping of messages. /// - public IList Tags { get; set; } = new List(); + public virtual IList Tags { get; set; } = new List(); /// /// additional external documentation for this message. /// - public AsyncApiExternalDocumentation ExternalDocs { get; set; } + public virtual AsyncApiExternalDocumentation ExternalDocs { get; set; } /// /// a map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the message. /// - public AsyncApiBindings Bindings { get; set; } = new AsyncApiBindings(); + public virtual AsyncApiBindings Bindings { get; set; } = new AsyncApiBindings(); /// /// list of examples. /// - public IList Examples { get; set; } = new List(); + public virtual IList Examples { get; set; } = new List(); /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public virtual IDictionary Extensions { get; set; } = new Dictionary(); - /// - public bool UnresolvedReference { get; set; } - - /// - public AsyncApiReference Reference { get; set; } - - public void SerializeV2(IAsyncApiWriter writer) - { - if (writer is null) - { - throw new ArgumentNullException(nameof(writer)); - } - - if (this.Reference != null && !writer.GetSettings().ShouldInlineReference(this.Reference)) - { - this.Reference.SerializeV2(writer); - return; - } - - this.SerializeV2WithoutReference(writer); - } - - public void SerializeV2WithoutReference(IAsyncApiWriter writer) + public virtual void SerializeV2(IAsyncApiWriter writer) { if (writer is null) { diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiOperationTrait.cs b/src/LEGO.AsyncAPI/Models/AsyncApiOperationTrait.cs index c7e0d10e..9260808e 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiOperationTrait.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiOperationTrait.cs @@ -10,7 +10,7 @@ namespace LEGO.AsyncAPI.Models /// /// Describes a trait that MAY be applied to an Operation Object. /// - public class AsyncApiOperationTrait : IAsyncApiExtensible, IAsyncApiReferenceable, IAsyncApiSerializable + public class AsyncApiOperationTrait : IAsyncApiExtensible, IAsyncApiSerializable { /// /// unique string used to identify the operation. @@ -18,59 +18,37 @@ public class AsyncApiOperationTrait : IAsyncApiExtensible, IAsyncApiReferenceabl /// /// The id MUST be unique among all operations described in the API. /// - public string OperationId { get; set; } + public virtual string OperationId { get; set; } /// /// a short summary of what the operation is about. /// - public string Summary { get; set; } + public virtual string Summary { get; set; } /// /// a short summary of what the operation is about. /// - public string Description { get; set; } + public virtual string Description { get; set; } /// /// a list of tags for API documentation control. Tags can be used for logical grouping of operations. /// - public IList Tags { get; set; } = new List(); + public virtual IList Tags { get; set; } = new List(); /// /// additional external documentation for this operation. /// - public AsyncApiExternalDocumentation ExternalDocs { get; set; } + public virtual AsyncApiExternalDocumentation ExternalDocs { get; set; } /// /// a map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the operation. /// - public AsyncApiBindings Bindings { get; set; } = new AsyncApiBindings(); + public virtual AsyncApiBindings Bindings { get; set; } = new AsyncApiBindings(); /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public virtual IDictionary Extensions { get; set; } = new Dictionary(); - /// - public bool UnresolvedReference { get; set; } - - /// - public AsyncApiReference Reference { get; set; } - - public void SerializeV2(IAsyncApiWriter writer) - { - if (writer is null) - { - throw new ArgumentNullException(nameof(writer)); - } - - if (this.Reference != null && !writer.GetSettings().ShouldInlineReference(this.Reference)) - { - this.Reference.SerializeV2(writer); - return; - } - - this.SerializeV2WithoutReference(writer); - } - - public void SerializeV2WithoutReference(IAsyncApiWriter writer) + public virtual void SerializeV2(IAsyncApiWriter writer) { if (writer is null) { diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiReference.cs b/src/LEGO.AsyncAPI/Models/AsyncApiReference.cs index 3e5fc986..c0292bb2 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiReference.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiReference.cs @@ -3,7 +3,6 @@ namespace LEGO.AsyncAPI.Models { using System; - using System.Linq; using LEGO.AsyncAPI.Exceptions; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiServer.cs b/src/LEGO.AsyncAPI/Models/AsyncApiServer.cs index d977d83e..396b65d9 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiServer.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiServer.cs @@ -2,7 +2,6 @@ namespace LEGO.AsyncAPI.Models { - using System; using System.Collections.Generic; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI/Models/Interfaces/IAsyncApiReferenceable.cs b/src/LEGO.AsyncAPI/Models/Interfaces/IAsyncApiReferenceable.cs index 54e344e4..b1de15ae 100644 --- a/src/LEGO.AsyncAPI/Models/Interfaces/IAsyncApiReferenceable.cs +++ b/src/LEGO.AsyncAPI/Models/Interfaces/IAsyncApiReferenceable.cs @@ -2,8 +2,6 @@ namespace LEGO.AsyncAPI.Models.Interfaces { - using LEGO.AsyncAPI.Writers; - public interface IAsyncApiReferenceable : IAsyncApiSerializable { /// diff --git a/src/LEGO.AsyncAPI/Models/References/AsyncApiChannelReference.cs b/src/LEGO.AsyncAPI/Models/References/AsyncApiChannelReference.cs index 56d393fe..dd4aa4e8 100644 --- a/src/LEGO.AsyncAPI/Models/References/AsyncApiChannelReference.cs +++ b/src/LEGO.AsyncAPI/Models/References/AsyncApiChannelReference.cs @@ -1,6 +1,7 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Models { - using System; using System.Collections.Generic; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI/Models/References/AsyncApiCorrelationIdReference.cs b/src/LEGO.AsyncAPI/Models/References/AsyncApiCorrelationIdReference.cs index f3edde84..5bc56e2b 100644 --- a/src/LEGO.AsyncAPI/Models/References/AsyncApiCorrelationIdReference.cs +++ b/src/LEGO.AsyncAPI/Models/References/AsyncApiCorrelationIdReference.cs @@ -1,6 +1,7 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Models { - using System; using System.Collections.Generic; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI/Models/References/AsyncApiMessageReference.cs b/src/LEGO.AsyncAPI/Models/References/AsyncApiMessageReference.cs index 944e867d..09bc4fe2 100644 --- a/src/LEGO.AsyncAPI/Models/References/AsyncApiMessageReference.cs +++ b/src/LEGO.AsyncAPI/Models/References/AsyncApiMessageReference.cs @@ -1,6 +1,7 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Models { - using System; using System.Collections.Generic; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI/Models/References/AsyncApiMessageTraitReference.cs b/src/LEGO.AsyncAPI/Models/References/AsyncApiMessageTraitReference.cs new file mode 100644 index 00000000..9beefe3b --- /dev/null +++ b/src/LEGO.AsyncAPI/Models/References/AsyncApiMessageTraitReference.cs @@ -0,0 +1,75 @@ +// Copyright (c) The LEGO Group. All rights reserved. + +namespace LEGO.AsyncAPI.Models +{ + using System.Collections.Generic; + using LEGO.AsyncAPI.Models.Interfaces; + using LEGO.AsyncAPI.Writers; + + /// + /// The definition of a message trait this application MAY use. + /// + public class AsyncApiMessageTraitReference : AsyncApiMessageTrait, IAsyncApiReferenceable + { + private AsyncApiMessageTrait target; + + private AsyncApiMessageTrait Target + { + get + { + this.target ??= this.Reference.HostDocument.ResolveReference(this.Reference); + return this.target; + } + } + + public AsyncApiMessageTraitReference(string reference) + { + this.Reference = new AsyncApiReference(reference, ReferenceType.MessageTrait); + } + + public override string MessageId { get => this.Target?.MessageId; set => this.Target.MessageId = value; } + + public override AsyncApiJsonSchema Headers { get => this.Target?.Headers; set => this.Target.Headers = value; } + + public override AsyncApiCorrelationId CorrelationId { get => this.Target?.CorrelationId; set => this.Target.CorrelationId = value; } + + public override string SchemaFormat { get => this.Target?.SchemaFormat; set => this.Target.SchemaFormat = value; } + + public override string ContentType { get => this.Target?.ContentType; set => this.Target.ContentType = value; } + + public override string Name { get => this.Target?.Name; set => this.Target.Name = value; } + + public override string Title { get => this.Target?.Title; set => this.Target.Title = value; } + + public override string Summary { get => this.Target?.Summary; set => this.Target.Summary = value; } + + public override string Description { get => this.Target?.Description; set => this.Target.Description = value; } + + public override IList Tags { get => this.Target?.Tags; set => this.Target.Tags = value; } + + public override AsyncApiExternalDocumentation ExternalDocs { get => this.Target?.ExternalDocs; set => this.Target.ExternalDocs = value; } + + public override AsyncApiBindings Bindings { get => this.Target?.Bindings; set => this.Target.Bindings = value; } + + public override IList Examples { get => this.Target?.Examples; set => this.Target.Examples = value; } + + public override IDictionary Extensions { get => this.Target?.Extensions; set => this.Target.Extensions = value; } + + public AsyncApiReference Reference { get; set; } + + public bool UnresolvedReference { get { return this.Target == null; } } + + public override void SerializeV2(IAsyncApiWriter writer) + { + if (!writer.GetSettings().ShouldInlineReference(this.Reference)) + { + this.Reference.SerializeV2(writer); + return; + } + else + { + this.Target.SerializeV2(writer); + } + } + } +} diff --git a/src/LEGO.AsyncAPI/Models/References/AsyncApiOperationTraitReference.cs b/src/LEGO.AsyncAPI/Models/References/AsyncApiOperationTraitReference.cs new file mode 100644 index 00000000..6968cc0c --- /dev/null +++ b/src/LEGO.AsyncAPI/Models/References/AsyncApiOperationTraitReference.cs @@ -0,0 +1,61 @@ +// Copyright (c) The LEGO Group. All rights reserved. + +namespace LEGO.AsyncAPI.Models +{ + using System.Collections.Generic; + using LEGO.AsyncAPI.Models.Interfaces; + using LEGO.AsyncAPI.Writers; + + /// + /// The definition of an operation trait this application MAY use. + /// + public class AsyncApiOperationTraitReference : AsyncApiOperationTrait, IAsyncApiReferenceable + { + private AsyncApiOperationTrait target; + + private AsyncApiOperationTrait Target + { + get + { + this.target ??= this.Reference.HostDocument.ResolveReference(this.Reference); + return this.target; + } + } + + public AsyncApiOperationTraitReference(string reference) + { + this.Reference = new AsyncApiReference(reference, ReferenceType.OperationTrait); + } + + public override string OperationId { get => this.Target?.OperationId; set => this.Target.OperationId = value; } + + public override string Summary { get => this.Target?.Summary; set => this.Target.Summary = value; } + + public override string Description { get => this.Target?.Description; set => this.Target.Description = value; } + + public override IList Tags { get => this.Target?.Tags; set => this.Target.Tags = value; } + + public override AsyncApiExternalDocumentation ExternalDocs { get => this.Target?.ExternalDocs; set => this.Target.ExternalDocs = value; } + + public override AsyncApiBindings Bindings { get => this.Target?.Bindings; set => this.Target.Bindings = value; } + + public override IDictionary Extensions { get => this.Target?.Extensions; set => this.Target.Extensions = value; } + + public AsyncApiReference Reference { get; set; } + + public bool UnresolvedReference { get { return this.Target == null; } } + + public override void SerializeV2(IAsyncApiWriter writer) + { + if (!writer.GetSettings().ShouldInlineReference(this.Reference)) + { + this.Reference.SerializeV2(writer); + return; + } + else + { + this.Target.SerializeV2(writer); + } + } + } +} diff --git a/src/LEGO.AsyncAPI/Models/References/AsyncApiParameterReference.cs b/src/LEGO.AsyncAPI/Models/References/AsyncApiParameterReference.cs index d0a9a677..65d23d0d 100644 --- a/src/LEGO.AsyncAPI/Models/References/AsyncApiParameterReference.cs +++ b/src/LEGO.AsyncAPI/Models/References/AsyncApiParameterReference.cs @@ -1,6 +1,7 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Models { - using System; using System.Collections.Generic; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI/Models/References/AsyncApiSecuritySchemeReference.cs b/src/LEGO.AsyncAPI/Models/References/AsyncApiSecuritySchemeReference.cs index c8cc559f..a38d95df 100644 --- a/src/LEGO.AsyncAPI/Models/References/AsyncApiSecuritySchemeReference.cs +++ b/src/LEGO.AsyncAPI/Models/References/AsyncApiSecuritySchemeReference.cs @@ -1,3 +1,5 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Models { using System; diff --git a/src/LEGO.AsyncAPI/Models/References/AsyncApiServerReference.cs b/src/LEGO.AsyncAPI/Models/References/AsyncApiServerReference.cs index 46e81e9f..66f163f6 100644 --- a/src/LEGO.AsyncAPI/Models/References/AsyncApiServerReference.cs +++ b/src/LEGO.AsyncAPI/Models/References/AsyncApiServerReference.cs @@ -2,7 +2,6 @@ namespace LEGO.AsyncAPI.Models { - using System; using System.Collections.Generic; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI/Models/References/AsyncApiServerVariableReference.cs b/src/LEGO.AsyncAPI/Models/References/AsyncApiServerVariableReference.cs index 6e9041ac..a6fbc3cf 100644 --- a/src/LEGO.AsyncAPI/Models/References/AsyncApiServerVariableReference.cs +++ b/src/LEGO.AsyncAPI/Models/References/AsyncApiServerVariableReference.cs @@ -1,6 +1,7 @@ +// Copyright (c) The LEGO Group. All rights reserved. + namespace LEGO.AsyncAPI.Models { - using System; using System.Collections.Generic; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs b/src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs index 728eb5db..2def4f53 100644 --- a/src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs +++ b/src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs @@ -1,15 +1,8 @@ // Copyright (c) The LEGO Group. All rights reserved. namespace LEGO.AsyncAPI.Services { - using System; - using System.Collections.Generic; - using System.Linq; - using LEGO.AsyncAPI.Exceptions; - using LEGO.AsyncAPI.Models; - using LEGO.AsyncAPI.Models.Interfaces; - /// /// This class is used to walk an AsyncApiDocument and convert unresolved references to references to populated objects. /// - + } \ No newline at end of file diff --git a/src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs b/src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs index b9f04140..7e33d3d7 100644 --- a/src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs +++ b/src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs @@ -513,8 +513,9 @@ private void Walk(IList traits) internal void Walk(AsyncApiOperationTrait trait, bool isComponent = false) { - if (trait == null || this.ProcessAsReference(trait, isComponent)) + if (trait is AsyncApiOperationTraitReference reference) { + this.Walk(reference as IAsyncApiReferenceable); return; } @@ -585,8 +586,9 @@ private void Walk(IList traits) internal void Walk(AsyncApiMessageTrait trait, bool isComponent = false) { - if (trait == null || this.ProcessAsReference(trait, isComponent)) + if (trait is AsyncApiMessageTraitReference reference) { + this.Walk(reference as IAsyncApiReferenceable); return; } diff --git a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiDocumentRules.cs b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiDocumentRules.cs index d866c4df..e82f3c7c 100644 --- a/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiDocumentRules.cs +++ b/src/LEGO.AsyncAPI/Validation/Rules/AsyncApiDocumentRules.cs @@ -67,7 +67,7 @@ public static class AsyncApiDocumentRules finally { context.Exit(); - } + } }); private static string GetKeySignature(string path) diff --git a/test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs b/test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs index e5695743..7b9315af 100644 --- a/test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs +++ b/test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs @@ -300,14 +300,7 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() OperationId = "receiveLightMeasurement", Traits = new List { - new AsyncApiOperationTrait() - { - Reference = new AsyncApiReference() - { - FragmentId = "kafka", - Type = ReferenceType.OperationTrait, - }, - }, + new AsyncApiOperationTraitReference("#/components/operationTraits/kafka"), }, Message = new List { @@ -330,18 +323,11 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() OperationId = "turnOn", Traits = new List { - new AsyncApiOperationTrait() - { - Reference = new AsyncApiReference() - { - FragmentId = "kafka", - Type = ReferenceType.OperationTrait, - }, - }, + new AsyncApiOperationTraitReference("#/components/operationTraits/kafka"), }, Message = new List { - new AsyncApiMessageReference("#/components/messages/turnOnOff") + new AsyncApiMessageReference("#/components/messages/turnOnOff"), }, }, }) @@ -360,25 +346,11 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() OperationId = "turnOff", Traits = new List { - new AsyncApiOperationTrait() - { - Reference = new AsyncApiReference() - { - FragmentId = "kafka", - Type = ReferenceType.OperationTrait, - }, - }, + new AsyncApiOperationTraitReference("#/components/operationTraits/kafka"), }, Message = new List { - new AsyncApiMessageReference("#/components/messages/turnOnOff") - { - Reference = new AsyncApiReference() - { - FragmentId = "turnOnOff", - Type = ReferenceType.Message, - }, - }, + new AsyncApiMessageReference("#/components/messages/turnOnOff"), }, }, }) @@ -397,14 +369,7 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() OperationId = "dimLight", Traits = new List { - new AsyncApiOperationTrait() - { - Reference = new AsyncApiReference() - { - FragmentId = "kafka", - Type = ReferenceType.OperationTrait, - }, - }, + new AsyncApiOperationTraitReference("#/components/operationTraits/kafka"), }, Message = new List { @@ -420,14 +385,7 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() ContentType = "application/json", Traits = new List() { - new AsyncApiMessageTrait() - { - Reference = new AsyncApiReference() - { - Type = ReferenceType.MessageTrait, - FragmentId = "commonHeaders", - }, - }, + new AsyncApiMessageTraitReference("#/components/messageTraits/commonHeaders"), }, Payload = new AsyncApiJsonSchemaPayload { @@ -445,14 +403,7 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Summary = "Command a particular streetlight to turn the lights on or off.", Traits = new List() { - new AsyncApiMessageTrait() - { - Reference = new AsyncApiReference() - { - Type = ReferenceType.MessageTrait, - FragmentId = "commonHeaders", - }, - }, + new AsyncApiMessageTraitReference("#/components/messageTraits/commonHeaders"), }, Payload = new AsyncApiJsonSchemaPayload() { @@ -470,14 +421,7 @@ public void AsyncApiDocument_WithStreetLightsExample_SerializesAndDeserializes() Summary = "Command a particular streetlight to dim the lights.", Traits = new List() { - new AsyncApiMessageTrait() - { - Reference = new AsyncApiReference() - { - Type = ReferenceType.MessageTrait, - FragmentId = "commonHeaders", - }, - }, + new AsyncApiMessageTraitReference("#/components/messageTraits/commonHeaders"), }, Payload = new AsyncApiJsonSchemaPayload() { diff --git a/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs b/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs index ebb7dfc3..a229b861 100644 --- a/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs +++ b/test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs @@ -5,7 +5,6 @@ namespace LEGO.AsyncAPI.Tests using System; using System.Collections.Generic; using System.Linq; - using System.Text.Json.Nodes; using FluentAssertions; using LEGO.AsyncAPI.Exceptions; using LEGO.AsyncAPI.Models; @@ -432,7 +431,7 @@ public void Read_WithBasicPlusSecuritySchemeDeserializes() [Test] public void Read_WithWrongReference_AddsError() { - var yaml = + var yaml = """ asyncapi: 2.3.0 info: diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/WebSockets/WebSocketBindings_Should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/WebSockets/WebSocketBindings_Should.cs index 51815a25..203177ac 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/WebSockets/WebSocketBindings_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/WebSockets/WebSocketBindings_Should.cs @@ -8,7 +8,7 @@ namespace LEGO.AsyncAPI.Tests.Bindings.WebSockets using LEGO.AsyncAPI.Models; using LEGO.AsyncAPI.Readers; using NUnit.Framework; - + public class WebSocketBindings_Should : TestBase { [Test] diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs index 1dfdc59a..c0b233fc 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs @@ -1,12 +1,12 @@ // Copyright (c) The LEGO Group. All rights reserved. -using System.Collections.Generic; -using System.Linq; -using LEGO.AsyncAPI.Models; -using NUnit.Framework; - namespace LEGO.AsyncAPI.Tests { + using System.Collections.Generic; + using System.Linq; + using LEGO.AsyncAPI.Models; + using NUnit.Framework; + public class AsyncApiAnyTests { [Test] diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs index 6cc21365..f300f97d 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiMessage_Should.cs @@ -126,7 +126,7 @@ public void AsyncApiMessage_WithNoSchemaFormat_DoesNotSerializeSchemaFormat() actual.Should() .BePlatformAgnosticEquivalentTo(expected); message.Should().BeEquivalentTo(deserializedMessage); - } + } [Test] public void AsyncApiMessage_WithJsonSchemaFormat_Serializes() diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs index 60b18811..945e6753 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs @@ -44,7 +44,7 @@ public class AsyncApiSchema_Should : TestBase ExternalDocs = new AsyncApiExternalDocumentation { Url = new Uri("http://example.com/externalDocs"), - }, + }, }; public static AsyncApiJsonSchema AdvancedSchemaObject = new AsyncApiJsonSchema diff --git a/test/LEGO.AsyncAPI.Tests/Validation/ValidationRuleTests.cs b/test/LEGO.AsyncAPI.Tests/Validation/ValidationRuleTests.cs index 5d9f7bec..2b1d3ebf 100644 --- a/test/LEGO.AsyncAPI.Tests/Validation/ValidationRuleTests.cs +++ b/test/LEGO.AsyncAPI.Tests/Validation/ValidationRuleTests.cs @@ -4,7 +4,6 @@ namespace LEGO.AsyncAPI.Tests.Validation { using FluentAssertions; using LEGO.AsyncAPI.Readers; - using LEGO.AsyncAPI.Validations; using NUnit.Framework; using System.Linq;