Skip to content

Commit f74afbc

Browse files
Potential fix for code scanning alert no. 2304: Missed opportunity to use Where
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent e355808 commit f74afbc

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/Microsoft.OpenApi/Models/JsonSchemaReference.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,7 @@ protected override void SetAdditional31MetadataFromMapNode(JsonObject jsonObject
133133
// Examples
134134
if (jsonObject.TryGetPropertyValue(OpenApiConstants.Examples, out var examplesNode) && examplesNode is JsonArray examplesArray)
135135
{
136-
Examples = new List<JsonNode>();
137-
foreach (var example in examplesArray)
138-
{
139-
if (example != null)
140-
{
141-
Examples.Add(example);
142-
}
143-
}
136+
Examples = examplesArray.Where(example => example != null).ToList();
144137
}
145138
}
146139
}

0 commit comments

Comments
 (0)