Skip to content

Commit

Permalink
Use Where for sequence filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieKimani1 committed Oct 24, 2024
1 parent ae0c5a0 commit a478bd2
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Models;

Expand Down Expand Up @@ -106,16 +107,13 @@ private static void ValidateMismatchedDataType(IValidationContext context,

if (examples != null)
{
foreach (var key in examples.Keys)
foreach (var key in examples.Keys.Where(k => examples[k] != null))
{
if (examples[key] != null)
{
context.Enter(key);
context.Enter("value");
RuleHelpers.ValidateDataTypeMismatch(context, ruleName, examples[key]?.Value, schema);
context.Exit();
context.Exit();
}
context.Enter(key);
context.Enter("value");
RuleHelpers.ValidateDataTypeMismatch(context, ruleName, examples[key]?.Value, schema);
context.Exit();
context.Exit();
}
}

Expand Down

0 comments on commit a478bd2

Please sign in to comment.