Skip to content

Commit e2fbdaf

Browse files
authored
refactor!: centralize reference resolution and implement specific reference types. (#203)
1 parent 7d39747 commit e2fbdaf

File tree

115 files changed

+2834
-2262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2834
-2262
lines changed

src/LEGO.AsyncAPI.Bindings/Sns/Condition.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ public static Condition Parse(ParseNode node)
3939
switch (node)
4040
{
4141
case MapNode mapNode:
42-
{
43-
var conditionValues = new Dictionary<string, Dictionary<string, StringOrStringList>>();
44-
foreach (var conditionNode in mapNode)
4542
{
46-
switch (conditionNode.Value)
43+
var conditionValues = new Dictionary<string, Dictionary<string, StringOrStringList>>();
44+
foreach (var conditionNode in mapNode)
4745
{
48-
case MapNode conditionValueNode:
49-
conditionValues.Add(conditionNode.Name, new Dictionary<string, StringOrStringList>(conditionValueNode.Select(x =>
50-
new KeyValuePair<string, StringOrStringList>(x.Name, StringOrStringList.Parse(x.Value)))
51-
.ToDictionary(x => x.Key, x => x.Value)));
52-
break;
53-
default:
54-
throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " +
55-
$"AWS condition values should be one or more key value pairs.");
46+
switch (conditionNode.Value)
47+
{
48+
case MapNode conditionValueNode:
49+
conditionValues.Add(conditionNode.Name, new Dictionary<string, StringOrStringList>(conditionValueNode.Select(x =>
50+
new KeyValuePair<string, StringOrStringList>(x.Name, StringOrStringList.Parse(x.Value)))
51+
.ToDictionary(x => x.Key, x => x.Value)));
52+
break;
53+
default:
54+
throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " +
55+
$"AWS condition values should be one or more key value pairs.");
56+
}
5657
}
57-
}
5858

59-
return new Condition(conditionValues);
60-
}
59+
return new Condition(conditionValues);
60+
}
6161

6262
default:
6363
throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " +

src/LEGO.AsyncAPI.Bindings/Sns/Principal.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) The LEGO Group. All rights reserved.
2+
13
namespace LEGO.AsyncAPI.Bindings.Sns;
24

35
using System;
@@ -28,20 +30,20 @@ public static Principal Parse(ParseNode node)
2830
return new PrincipalStar();
2931

3032
case MapNode mapNode:
31-
{
32-
var propertyNode = mapNode.First();
33-
if (!IsValidPrincipalProperty(propertyNode.Name))
3433
{
35-
throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " +
36-
$"Node should contain a valid AWS principal property name.");
37-
}
34+
var propertyNode = mapNode.First();
35+
if (!IsValidPrincipalProperty(propertyNode.Name))
36+
{
37+
throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " +
38+
$"Node should contain a valid AWS principal property name.");
39+
}
3840

39-
var principalValue = new KeyValuePair<string, StringOrStringList>(
40-
propertyNode.Name,
41-
StringOrStringList.Parse(propertyNode.Value));
41+
var principalValue = new KeyValuePair<string, StringOrStringList>(
42+
propertyNode.Name,
43+
StringOrStringList.Parse(propertyNode.Value));
4244

43-
return new PrincipalObject(principalValue);
44-
}
45+
return new PrincipalObject(principalValue);
46+
}
4547

4648
default:
4749
throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " +

src/LEGO.AsyncAPI.Bindings/Sns/PrincipalObject.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) The LEGO Group. All rights reserved.
2+
13
namespace LEGO.AsyncAPI.Bindings.Sns;
24

35
using System;

src/LEGO.AsyncAPI.Bindings/Sns/PrincipalStar.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) The LEGO Group. All rights reserved.
2+
13
namespace LEGO.AsyncAPI.Bindings.Sns;
24

35
using System;

src/LEGO.AsyncAPI.Bindings/Sns/SnsOperationBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class SnsOperationBinding : OperationBinding<SnsOperationBinding>
5959

6060
private FixedFieldMap<RedrivePolicy> redrivePolicyFixedFields => new()
6161
{
62-
{ "deadLetterQueue", (a, n) => { a.DeadLetterQueue = n.ParseMapWithExtensions(identifierFixFields); } },
62+
{ "deadLetterQueue", (a, n) => { a.DeadLetterQueue = n.ParseMapWithExtensions(this.identifierFixFields); } },
6363
{ "maxReceiveCount", (a, n) => { a.MaxReceiveCount = n.GetIntegerValue(); } },
6464
};
6565

src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ namespace LEGO.AsyncAPI.Bindings.Sns
44
using System;
55
using System.Collections.Generic;
66
using LEGO.AsyncAPI.Attributes;
7-
using LEGO.AsyncAPI.Models;
87
using LEGO.AsyncAPI.Models.Interfaces;
98
using LEGO.AsyncAPI.Writers;
109

src/LEGO.AsyncAPI.Bindings/Sqs/Condition.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ public static Condition Parse(ParseNode node)
3939
switch (node)
4040
{
4141
case MapNode mapNode:
42-
{
43-
var conditionValues = new Dictionary<string, Dictionary<string, StringOrStringList>>();
44-
foreach (var conditionNode in mapNode)
4542
{
46-
switch (conditionNode.Value)
43+
var conditionValues = new Dictionary<string, Dictionary<string, StringOrStringList>>();
44+
foreach (var conditionNode in mapNode)
4745
{
48-
case MapNode conditionValueNode:
49-
conditionValues.Add(conditionNode.Name, new Dictionary<string, StringOrStringList>(conditionValueNode.Select(x =>
50-
new KeyValuePair<string, StringOrStringList>(x.Name, StringOrStringList.Parse(x.Value)))
51-
.ToDictionary(x => x.Key, x => x.Value)));
52-
break;
53-
default:
54-
throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " +
55-
$"AWS condition values should be one or more key value pairs.");
46+
switch (conditionNode.Value)
47+
{
48+
case MapNode conditionValueNode:
49+
conditionValues.Add(conditionNode.Name, new Dictionary<string, StringOrStringList>(conditionValueNode.Select(x =>
50+
new KeyValuePair<string, StringOrStringList>(x.Name, StringOrStringList.Parse(x.Value)))
51+
.ToDictionary(x => x.Key, x => x.Value)));
52+
break;
53+
default:
54+
throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " +
55+
$"AWS condition values should be one or more key value pairs.");
56+
}
5657
}
57-
}
5858

59-
return new Condition(conditionValues);
60-
}
59+
return new Condition(conditionValues);
60+
}
6161

6262
default:
6363
throw new ArgumentException($"An error occured while parsing a {nameof(Condition)} node. " +

src/LEGO.AsyncAPI.Bindings/Sqs/Principal.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ public static Principal Parse(ParseNode node)
3030
return new PrincipalStar();
3131

3232
case MapNode mapNode:
33-
{
34-
var propertyNode = mapNode.First();
35-
if (!IsValidPrincipalProperty(propertyNode.Name))
3633
{
37-
throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " +
38-
$"Node should contain a valid AWS principal property name.");
39-
}
34+
var propertyNode = mapNode.First();
35+
if (!IsValidPrincipalProperty(propertyNode.Name))
36+
{
37+
throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " +
38+
$"Node should contain a valid AWS principal property name.");
39+
}
4040

41-
var principalValue = new KeyValuePair<string, StringOrStringList>(
42-
propertyNode.Name,
43-
StringOrStringList.Parse(propertyNode.Value));
41+
var principalValue = new KeyValuePair<string, StringOrStringList>(
42+
propertyNode.Name,
43+
StringOrStringList.Parse(propertyNode.Value));
4444

45-
return new PrincipalObject(principalValue);
46-
}
45+
return new PrincipalObject(principalValue);
46+
}
4747

4848
default:
4949
throw new ArgumentException($"An error occured while parsing a {nameof(Principal)} node. " +

src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalObject.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) The LEGO Group. All rights reserved.
2+
13
namespace LEGO.AsyncAPI.Bindings.Sqs;
24

35
using System;

src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalStar.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) The LEGO Group. All rights reserved.
2+
13
namespace LEGO.AsyncAPI.Bindings.Sqs;
24

35
using System;

src/LEGO.AsyncAPI.Bindings/Sqs/Statement.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace LEGO.AsyncAPI.Bindings.Sqs
55
using System;
66
using System.Collections.Generic;
77
using LEGO.AsyncAPI.Attributes;
8-
using LEGO.AsyncAPI.Models;
98
using LEGO.AsyncAPI.Models.Interfaces;
109
using LEGO.AsyncAPI.Writers;
1110

src/LEGO.AsyncAPI.Readers/AsyncApiDiagnostics.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,18 @@ public class AsyncApiDiagnostic : IDiagnostic
1313
public IList<AsyncApiError> Warnings { get; set; } = new List<AsyncApiError>();
1414

1515
public AsyncApiVersion SpecificationVersion { get; set; }
16+
17+
public void Append(AsyncApiDiagnostic diagnosticToAdd)
18+
{
19+
foreach (var error in diagnosticToAdd.Errors)
20+
{
21+
this.Errors.Add(new(error.Pointer, error.Message));
22+
}
23+
24+
foreach (var warning in diagnosticToAdd.Warnings)
25+
{
26+
this.Warnings.Add(new(warning.Pointer, warning.Message));
27+
}
28+
}
1629
}
1730
}

0 commit comments

Comments
 (0)