Skip to content

Commit 8f94228

Browse files
committed
refactor(document): extract GetOperationsFromPathItems to eliminate duplicate iteration
1 parent 96cad35 commit 8f94228

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -877,16 +877,17 @@ static bool AddToDictionary<TValue>(IDictionary<string, TValue> dict, string key
877877

878878
private IEnumerable<OpenApiOperation> GetAllOperations()
879879
{
880-
foreach (var pathItem in Paths.Values)
881-
{
882-
if (pathItem.Operations is null) continue;
883-
foreach (var operation in pathItem.Operations.Values)
884-
yield return operation;
885-
}
880+
foreach (var operation in GetOperationsFromPathItems(Paths))
881+
yield return operation;
886882

887-
if (Webhooks is null) yield break;
883+
if (Webhooks is not null)
884+
foreach (var operation in GetOperationsFromPathItems(Webhooks))
885+
yield return operation;
886+
}
888887

889-
foreach (var pathItem in Webhooks.Values)
888+
private static IEnumerable<OpenApiOperation> GetOperationsFromPathItems(IDictionary<string, IOpenApiPathItem> pathItems)
889+
{
890+
foreach (var pathItem in pathItems.Values)
890891
{
891892
if (pathItem.Operations is null) continue;
892893
foreach (var operation in pathItem.Operations.Values)

0 commit comments

Comments
 (0)