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

+4
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

+5
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

+1-2
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

+3-3
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

+10-10
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

+3-3
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

+3-3
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

+2-4
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

+3-4
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

+1-1
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
}

src/LEGO.AsyncAPI/Models/AsyncApiComponents.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) The LEGO Group. All rights reserved.
1+
// Copyright (c) The LEGO Group. All rights reserved.
22

33
namespace LEGO.AsyncAPI.Models
44
{
@@ -347,7 +347,7 @@ public void SerializeV2(IAsyncApiWriter writer)
347347
});
348348

349349
// extensions
350-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
350+
writer.WriteExtensions(this.Extensions);
351351

352352
writer.WriteEndObject();
353353
}

src/LEGO.AsyncAPI/Models/AsyncApiContact.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void SerializeV2(IAsyncApiWriter writer)
4949
writer.WriteOptionalProperty(AsyncApiConstants.Email, this.Email);
5050

5151
// extensions
52-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
52+
writer.WriteExtensions(this.Extensions);
5353

5454
writer.WriteEndObject();
5555
}

src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class AsyncApiDocument : IAsyncApiExtensible, IAsyncApiSerializable
2020
public string Asyncapi { get; set; }
2121

2222
/// <summary>
23-
///identifier of the application the AsyncAPI document is defining.
23+
/// Identifier of the application the AsyncAPI document is defining.
2424
/// </summary>
2525
public string Id { get; set; }
2626

@@ -127,7 +127,7 @@ public void SerializeV2(IAsyncApiWriter writer)
127127
writer.WriteOptionalObject(AsyncApiConstants.ExternalDocs, this.ExternalDocs, (w, e) => e.SerializeV2(w));
128128

129129
// extensions
130-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
130+
writer.WriteExtensions(this.Extensions);
131131

132132
writer.WriteEndObject();
133133
}

src/LEGO.AsyncAPI/Models/AsyncApiExternalDocumentation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void SerializeV2(IAsyncApiWriter writer)
3838

3939
writer.WriteRequiredProperty(AsyncApiConstants.Url, this.Url?.OriginalString);
4040

41-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
41+
writer.WriteExtensions(this.Extensions);
4242

4343
writer.WriteEndObject();
4444
}

src/LEGO.AsyncAPI/Models/AsyncApiInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void SerializeV2(IAsyncApiWriter writer)
7373
writer.WriteOptionalProperty(AsyncApiConstants.Version, this.Version);
7474

7575
// specification extensions
76-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
76+
writer.WriteExtensions(this.Extensions);
7777

7878
writer.WriteEndObject();
7979
}

src/LEGO.AsyncAPI/Models/AsyncApiLicense.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void SerializeV2(IAsyncApiWriter writer)
4141
writer.WriteOptionalProperty(AsyncApiConstants.Url, this.Url?.OriginalString);
4242

4343
// specification extensions
44-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
44+
writer.WriteExtensions(this.Extensions);
4545

4646
writer.WriteEndObject();
4747
}

src/LEGO.AsyncAPI/Models/AsyncApiMessage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
134134
writer.WriteOptionalCollection(AsyncApiConstants.Examples, this.Examples, (w, e) => e.SerializeV2(w));
135135

136136
writer.WriteOptionalCollection(AsyncApiConstants.Traits, this.Traits, (w, t) => t.SerializeV2(w));
137-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
137+
writer.WriteExtensions(this.Extensions);
138138
writer.WriteEndObject();
139139
}
140140
}

src/LEGO.AsyncAPI/Models/AsyncApiMessageExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void SerializeV2(IAsyncApiWriter writer)
4747
writer.WriteOptionalProperty(AsyncApiConstants.Summary, this.Summary);
4848
writer.WriteOptionalMap(AsyncApiConstants.Headers, this.Headers, (w, h) => w.WriteAny(h));
4949
writer.WriteOptionalObject(AsyncApiConstants.Payload, this.Payload, (w, p) => w.WriteAny(p));
50-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
50+
writer.WriteExtensions(this.Extensions);
5151
writer.WriteEndObject();
5252
}
5353
}

src/LEGO.AsyncAPI/Models/AsyncApiMessageTrait.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
120120
writer.WriteOptionalObject(AsyncApiConstants.ExternalDocs, this.ExternalDocs, (w, e) => e.SerializeV2(w));
121121
writer.WriteOptionalObject(AsyncApiConstants.Bindings, this.Bindings, (w, t) => t.SerializeV2(w));
122122
writer.WriteOptionalCollection(AsyncApiConstants.Examples, this.Examples, (w, e) => e.SerializeV2(w));
123-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
123+
writer.WriteExtensions(this.Extensions);
124124
writer.WriteEndObject();
125125
}
126126
}

src/LEGO.AsyncAPI/Models/AsyncApiOAuthFlow.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void SerializeV2(IAsyncApiWriter writer)
6161
writer.WriteRequiredMap(AsyncApiConstants.Scopes, this.Scopes, (w, s) => w.WriteValue(s));
6262

6363
// extensions
64-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
64+
writer.WriteExtensions(this.Extensions);
6565

6666
writer.WriteEndObject();
6767
}

src/LEGO.AsyncAPI/Models/AsyncApiOAuthFlows.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void SerializeV2(IAsyncApiWriter writer)
6868
(w, o) => o.SerializeV2(w));
6969

7070
// extensions
71-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
71+
writer.WriteExtensions(this.Extensions);
7272

7373
writer.WriteEndObject();
7474
}

src/LEGO.AsyncAPI/Models/AsyncApiOperation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void SerializeV2(IAsyncApiWriter writer)
8787
writer.WriteOptionalObject(AsyncApiConstants.Message, this.Message.FirstOrDefault(), (w, m) => m.SerializeV2(w));
8888
}
8989

90-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
90+
writer.WriteExtensions(this.Extensions);
9191
writer.WriteEndObject();
9292
}
9393
}

src/LEGO.AsyncAPI/Models/AsyncApiOperationTrait.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
8585
writer.WriteOptionalCollection(AsyncApiConstants.Tags, this.Tags, (w, t) => t.SerializeV2(w));
8686
writer.WriteOptionalObject(AsyncApiConstants.ExternalDocs, this.ExternalDocs, (w, e) => e.SerializeV2(w));
8787
writer.WriteOptionalObject(AsyncApiConstants.Bindings, this.Bindings, (w, t) => t.SerializeV2(w));
88-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
88+
writer.WriteExtensions(this.Extensions);
8989

9090
writer.WriteEndObject();
9191
}

src/LEGO.AsyncAPI/Models/AsyncApiParameter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
6363
writer.WriteOptionalProperty(AsyncApiConstants.Description, this.Description);
6464
writer.WriteOptionalObject(AsyncApiConstants.Schema, this.Schema, (w, s) => s.SerializeV2(w));
6565
writer.WriteOptionalProperty(AsyncApiConstants.Location, this.Location);
66-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
66+
writer.WriteExtensions(this.Extensions);
6767
writer.WriteEndObject();
6868
}
6969
}

src/LEGO.AsyncAPI/Models/AsyncApiSchema.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
378378
writer.WriteOptionalProperty(AsyncApiConstants.Deprecated, this.Deprecated, false);
379379

380380
// extensions
381-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
381+
writer.WriteExtensions(this.Extensions);
382382

383383
writer.WriteEndObject();
384384
}

src/LEGO.AsyncAPI/Models/AsyncApiSecurityScheme.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
141141
}
142142

143143
// extensions
144-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
144+
writer.WriteExtensions(this.Extensions);
145145

146146
writer.WriteEndObject();
147147
}

src/LEGO.AsyncAPI/Models/AsyncApiServer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
9090
writer.WriteOptionalCollection(AsyncApiConstants.Security, this.Security, (w, s) => s.SerializeV2(w));
9191

9292
writer.WriteOptionalObject(AsyncApiConstants.Bindings, this.Bindings, (w, t) => t.SerializeV2(w));
93-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
93+
writer.WriteExtensions(this.Extensions);
9494

9595
writer.WriteEndObject();
9696
}

src/LEGO.AsyncAPI/Models/AsyncApiServerVariable.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void SerializeV2(IAsyncApiWriter writer)
5757
writer.WriteOptionalCollection(AsyncApiConstants.Examples, this.Examples, (w, e) => w.WriteValue(e));
5858

5959
// specification extensions
60-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
60+
writer.WriteExtensions(this.Extensions);
6161

6262
writer.WriteEndObject();
6363
}

src/LEGO.AsyncAPI/Models/AsyncApiTag.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void SerializeV2(IAsyncApiWriter writer)
4444

4545
writer.WriteOptionalObject(AsyncApiConstants.ExternalDocs, this.ExternalDocs, (w, e) => e.SerializeV2(w));
4646

47-
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);
47+
writer.WriteExtensions(this.Extensions);
4848

4949
writer.WriteEndObject();
5050
}

src/LEGO.AsyncAPI/Models/Interfaces/IAsyncApiExtension.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace LEGO.AsyncAPI.Models.Interfaces
66

77
public interface IAsyncApiExtension
88
{
9-
void Write(IAsyncApiWriter writer, AsyncApiVersion specVersion);
9+
void Write(IAsyncApiWriter writer);
1010
}
1111
}

0 commit comments

Comments
 (0)