Skip to content

Commit 84e83f4

Browse files
committed
chore: reduces loops
Signed-off-by: Vincent Biret <[email protected]>
1 parent b9ef21d commit 84e83f4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT license.
33

44
using System;
5+
using System.Linq;
56
using Microsoft.OpenApi.Interfaces;
67
using Microsoft.OpenApi.Properties;
78

@@ -21,13 +22,10 @@ public static class OpenApiExtensibleRules
2122
(context, item) =>
2223
{
2324
context.Enter("extensions");
24-
foreach (var extensible in item.Extensions)
25+
foreach (var extensible in item.Extensions.Keys.Where(static x => !x.StartsWith("x-", StringComparison.OrdinalIgnoreCase)))
2526
{
26-
if (!extensible.Key.StartsWith("x-"))
27-
{
28-
context.CreateError(nameof(ExtensionNameMustStartWithXDash),
29-
String.Format(SRResource.Validation_ExtensionNameMustBeginWithXDash, extensible.Key, context.PathString));
30-
}
27+
context.CreateError(nameof(ExtensionNameMustStartWithXDash),
28+
string.Format(SRResource.Validation_ExtensionNameMustBeginWithXDash, extensible, context.PathString));
3129
}
3230
context.Exit();
3331
});

0 commit comments

Comments
 (0)