Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/LEGO.AsyncAPI.Bindings/Sns/Condition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ public static Condition Parse(ParseNode node)
switch (node)
{
case MapNode mapNode:
{
var conditionValues = new Dictionary<string, Dictionary<string, StringOrStringList>>();
foreach (var conditionNode in mapNode)
{
switch (conditionNode.Value)
var conditionValues = new Dictionary<string, Dictionary<string, StringOrStringList>>();
foreach (var conditionNode in mapNode)
{
case MapNode conditionValueNode:
conditionValues.Add(conditionNode.Name, new Dictionary<string, StringOrStringList>(conditionValueNode.Select(x =>
new KeyValuePair<string, StringOrStringList>(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<string, StringOrStringList>(conditionValueNode.Select(x =>
new KeyValuePair<string, StringOrStringList>(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. " +
Expand Down
24 changes: 13 additions & 11 deletions src/LEGO.AsyncAPI.Bindings/Sns/Principal.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Bindings.Sns;

using System;
Expand Down Expand Up @@ -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<string, StringOrStringList>(
propertyNode.Name,
StringOrStringList.Parse(propertyNode.Value));
var principalValue = new KeyValuePair<string, StringOrStringList>(
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. " +
Expand Down
2 changes: 2 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sns/PrincipalObject.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Bindings.Sns;

using System;
Expand Down
2 changes: 2 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sns/PrincipalStar.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Bindings.Sns;

using System;
Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI.Bindings/Sns/SnsOperationBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class SnsOperationBinding : OperationBinding<SnsOperationBinding>

private FixedFieldMap<RedrivePolicy> redrivePolicyFixedFields => new()
{
{ "deadLetterQueue", (a, n) => { a.DeadLetterQueue = n.ParseMapWithExtensions(identifierFixFields); } },
{ "deadLetterQueue", (a, n) => { a.DeadLetterQueue = n.ParseMapWithExtensions(this.identifierFixFields); } },
{ "maxReceiveCount", (a, n) => { a.MaxReceiveCount = n.GetIntegerValue(); } },
};

Expand Down
1 change: 0 additions & 1 deletion src/LEGO.AsyncAPI.Bindings/Sns/Statement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
30 changes: 15 additions & 15 deletions src/LEGO.AsyncAPI.Bindings/Sqs/Condition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ public static Condition Parse(ParseNode node)
switch (node)
{
case MapNode mapNode:
{
var conditionValues = new Dictionary<string, Dictionary<string, StringOrStringList>>();
foreach (var conditionNode in mapNode)
{
switch (conditionNode.Value)
var conditionValues = new Dictionary<string, Dictionary<string, StringOrStringList>>();
foreach (var conditionNode in mapNode)
{
case MapNode conditionValueNode:
conditionValues.Add(conditionNode.Name, new Dictionary<string, StringOrStringList>(conditionValueNode.Select(x =>
new KeyValuePair<string, StringOrStringList>(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<string, StringOrStringList>(conditionValueNode.Select(x =>
new KeyValuePair<string, StringOrStringList>(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. " +
Expand Down
22 changes: 11 additions & 11 deletions src/LEGO.AsyncAPI.Bindings/Sqs/Principal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, StringOrStringList>(
propertyNode.Name,
StringOrStringList.Parse(propertyNode.Value));
var principalValue = new KeyValuePair<string, StringOrStringList>(
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. " +
Expand Down
2 changes: 2 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalObject.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Bindings.Sqs;

using System;
Expand Down
2 changes: 2 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sqs/PrincipalStar.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Bindings.Sqs;

using System;
Expand Down
1 change: 0 additions & 1 deletion src/LEGO.AsyncAPI.Bindings/Sqs/Statement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 13 additions & 0 deletions src/LEGO.AsyncAPI.Readers/AsyncApiDiagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,18 @@ public class AsyncApiDiagnostic : IDiagnostic
public IList<AsyncApiError> Warnings { get; set; } = new List<AsyncApiError>();

public AsyncApiVersion SpecificationVersion { get; set; }

public void Append(AsyncApiDiagnostic diagnosticToAdd)
{
foreach (var error in diagnosticToAdd.Errors)
{
this.Errors.Add(new(error.Pointer, error.Message));
}

foreach (var warning in diagnosticToAdd.Warnings)
{
this.Warnings.Add(new(warning.Pointer, warning.Message));
}
}
}
}
Loading
Loading