Skip to content

Commit

Permalink
fix prune
Browse files Browse the repository at this point in the history
  • Loading branch information
rucciva committed Jun 18, 2024
1 parent 5a7ec82 commit c5d6dae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/proxy/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ func (pe *ProxyExtension) pruneAndPrefixUpstream(ctx context.Context) (err error
opmap[uop] = struct{}{}
uop.OperationId = util.MapFirstEntry(popmap).Key.GetName() + uop.OperationId
}

// delete unused operations and path items
unusedPathItem := map[string]struct{}{}
for m := range orderedmap.Iterate(ctx, docv3.Model.Paths.PathItems) {
pathItem := m.Value()
for method, op := range util.GetOperationsMap(pathItem) {
Expand All @@ -159,9 +161,12 @@ func (pe *ProxyExtension) pruneAndPrefixUpstream(ctx context.Context) (err error
util.SetOperation(pathItem, method, nil)
}
if len(util.GetOperationsMap(pathItem)) == 0 {
docv3.Model.Paths.PathItems.Delete(m.Key())
unusedPathItem[m.Key()] = struct{}{}
}
}
for pi := range unusedPathItem {
docv3.Model.Paths.PathItems.Delete(pi)
}

// recreate the doc so that we could get references of used operations only
// also add components with prefix so that it doesn't trigger error log from libopenapi
Expand Down

0 comments on commit c5d6dae

Please sign in to comment.