Skip to content

Commit 227c714

Browse files
authored
refactor: removed version from write logic as it was not needed. (#75)
1 parent c5d9202 commit 227c714

32 files changed

+63
-55
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.cs]
2+
3+
# SA1623: Property summary documentation should match accessors
4+
dotnet_diagnostic.SA1623.severity = suggestion

AsyncAPI.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LEGO.AsyncAPI", "src\LEGO.A
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LEGO.AsyncAPI.Readers", "src\LEGO.AsyncAPI.Readers\LEGO.AsyncAPI.Readers.csproj", "{7D9C6FBA-4B6F-48A0-B3F5-E7357021F8F9}"
1111
EndProject
12+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DE167614-5BCB-4046-BD4C-ABB70E9F3462}"
13+
ProjectSection(SolutionItems) = preProject
14+
.editorconfig = .editorconfig
15+
EndProjectSection
16+
EndProject
1217
Global
1318
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1419
Debug|Any CPU = Debug|Any CPU

src/LEGO.AsyncAPI.Readers/AsyncApiDeserializer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ private static IAsyncApiExtension LoadExtension(string name, ParseNode node)
168168
if (node.Context.ExtensionParsers.TryGetValue(name, out var parser))
169169
{
170170
return parser(
171-
AsyncApiAnyConverter.GetSpecificAsyncApiAny(node.CreateAny()),
172-
AsyncApiVersion.AsyncApi2_3_0);
171+
AsyncApiAnyConverter.GetSpecificAsyncApiAny(node.CreateAny()));
173172
}
174173
else
175174
{

src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public class AsyncApiReaderSettings
3434
ReferenceResolutionSetting.ResolveReferences;
3535

3636
/// <summary>
37-
/// Dictionary of parsers for converting extensions into strongly typed classes
37+
/// Dictionary of parsers for converting extensions into strongly typed classes.
3838
/// </summary>
39-
public Dictionary<string, Func<IAsyncApiAny, AsyncApiVersion, IAsyncApiExtension>>
39+
public Dictionary<string, Func<IAsyncApiAny, IAsyncApiExtension>>
4040
ExtensionParsers
4141
{ get; set; } =
42-
new Dictionary<string, Func<IAsyncApiAny, AsyncApiVersion, IAsyncApiExtension>>();
42+
new Dictionary<string, Func<IAsyncApiAny, IAsyncApiExtension>>();
4343

4444
/// <summary>
4545
/// Rules to use for validating AsyncApi specification. If none are provided a default set of rules are applied.

src/LEGO.AsyncAPI.Readers/ParsingContext.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ namespace LEGO.AsyncAPI.Readers
1414

1515
public class ParsingContext
1616
{
17-
private readonly Stack<string> _currentLocation = new();
18-
private readonly Dictionary<string, object> tempStorage = new();
19-
private readonly Dictionary<object, Dictionary<string, object>> scopedTempStorage = new();
20-
private readonly Dictionary<string, Stack<string>> loopStacks = new();
17+
private readonly Stack<string> currentLocation = new ();
18+
private readonly Dictionary<string, object> tempStorage = new ();
19+
private readonly Dictionary<object, Dictionary<string, object>> scopedTempStorage = new ();
20+
private readonly Dictionary<string, Stack<string>> loopStacks = new ();
2121

22-
internal Dictionary<string, Func<IAsyncApiAny, AsyncApiVersion, IAsyncApiExtension>> ExtensionParsers
22+
internal Dictionary<string, Func<IAsyncApiAny, IAsyncApiExtension>> ExtensionParsers
2323
{
2424
get;
2525
set;
2626
}
2727

28-
= new();
28+
= new ();
2929

3030
internal RootNode RootNode { get; set; }
3131

32-
internal List<AsyncApiTag> Tags { get; private set; } = new();
32+
internal List<AsyncApiTag> Tags { get; private set; } = new ();
3333

3434
public AsyncApiDiagnostic Diagnostic { get; }
3535

@@ -94,13 +94,13 @@ private static string GetVersion(RootNode rootNode)
9494

9595
public void EndObject()
9696
{
97-
this._currentLocation.Pop();
97+
this.currentLocation.Pop();
9898
}
9999

100100
public string GetLocation()
101101
{
102102
return "#/" + string.Join("/",
103-
this._currentLocation.Reverse().Select(s => s.Replace("~", "~0").Replace("/", "~1")).ToArray());
103+
this.currentLocation.Reverse().Select(s => s.Replace("~", "~0").Replace("/", "~1")).ToArray());
104104
}
105105

106106
public T GetFromTempStorage<T>(string key, object scope = null)
@@ -144,7 +144,7 @@ public void SetTempStorage(string key, object value, object scope = null)
144144

145145
public void StartObject(string objectName)
146146
{
147-
this._currentLocation.Push(objectName);
147+
this.currentLocation.Push(objectName);
148148
}
149149

150150
public bool PushLoop(string loopId, string key)

src/LEGO.AsyncAPI/Models/Any/AsyncAPIArray.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ namespace LEGO.AsyncAPI.Models.Any
1212
public class AsyncApiArray : List<IAsyncApiAny>, IAsyncApiAny
1313
{
1414
/// <summary>
15-
/// The type of <see cref="IAsyncApiAny"/>
15+
/// The type of <see cref="IAsyncApiAny"/>.
1616
/// </summary>
1717
public AnyType AnyType { get; } = AnyType.Array;
1818

1919
/// <summary>
20-
/// Write out contents of AsyncApiArray to passed writer
20+
/// Write out contents of AsyncApiArray to passed writer.
2121
/// </summary>
2222
/// <param name="writer">Instance of JSON or YAML writer.</param>
23-
public void Write(IAsyncApiWriter writer, AsyncApiVersion asyncApiVersion)
23+
public void Write(IAsyncApiWriter writer)
2424
{
2525
writer.WriteStartArray();
2626

src/LEGO.AsyncAPI/Models/Any/AsyncAPINull.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ namespace LEGO.AsyncAPI.Models.Any
1111
public class AsyncApiNull : IAsyncApiAny
1212
{
1313
/// <summary>
14-
/// The type of <see cref="IAsyncApiAny"/>
14+
/// The type of <see cref="IAsyncApiAny"/>.
1515
/// </summary>
1616
public AnyType AnyType { get; } = AnyType.Null;
1717

1818
/// <summary>
19-
/// Write out null representation
19+
/// Write out null representation.
2020
/// </summary>
2121
/// <param name="writer"></param>
22-
public void Write(IAsyncApiWriter writer, AsyncApiVersion asyncApiVersion)
22+
public void Write(IAsyncApiWriter writer)
2323
{
2424
writer.WriteAny(this);
2525
}

src/LEGO.AsyncAPI/Models/Any/AsyncAPIObject.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ public class AsyncApiObject : Dictionary<string, IAsyncApiAny>, IAsyncApiAny
1717
public AnyType AnyType { get; } = AnyType.Object;
1818

1919
/// <summary>
20-
/// Serialize AsyncApiObject to writer
20+
/// Serialize AsyncApiObject to writer.
2121
/// </summary>
22-
/// <param name="writer"></param>
23-
/// <param name="specVersion">Version of the AsyncApi specification that that will be output.</param>
24-
public void Write(IAsyncApiWriter writer, AsyncApiVersion asyncApiVersion)
22+
public void Write(IAsyncApiWriter writer)
2523
{
2624
writer.WriteStartObject();
2725

src/LEGO.AsyncAPI/Models/Any/AsyncApiPrimitive{T}.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ public AsyncApiPrimitive(T value)
3333
public abstract PrimitiveType PrimitiveType { get; }
3434

3535
/// <summary>
36-
/// Value of this <see cref="IAsyncApiPrimitive"/>
36+
/// Value of this <see cref="IAsyncApiPrimitive"/>.
3737
/// </summary>
3838
public T Value { get; }
3939

4040
/// <summary>
41-
/// Write out content of primitive element
41+
/// Write out content of primitive element.
4242
/// </summary>
4343
/// <param name="writer"></param>
44-
/// <param name="specVersion"></param>
45-
public void Write(IAsyncApiWriter writer, AsyncApiVersion specVersion)
44+
public void Write(IAsyncApiWriter writer)
4645
{
4746
switch (this.PrimitiveType)
4847
{

src/LEGO.AsyncAPI/Models/AsyncApiChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
107107
writer.WriteOptionalObject(AsyncApiConstants.Bindings, this.Bindings, (w, t) => t.SerializeV2(w));
108108

109109
// extensions
110-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
110+
writer.WriteExtensions(this.Extensions);
111111

112112
writer.WriteEndObject();
113113
}

0 commit comments

Comments
 (0)