Skip to content

Commit

Permalink
Added GetAllReferences() and GetAllMappedReferences() methods to Rolodex
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvin Lobo committed Sep 10, 2024
1 parent 4f01483 commit 440ff38
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions functions/openapi/unused_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
"maps"
"strings"
)

Expand Down Expand Up @@ -40,11 +39,7 @@ func (uc UnusedComponent) RunRule(nodes []*yaml.Node, context model.RuleFunction
var results []model.RuleFunctionResult

// extract all references, and every single component, recursively
allRefs := context.Document.GetRolodex().GetRootIndex().GetAllReferences()
for _, idx := range context.Document.GetRolodex().GetIndexes() {
refs := idx.GetAllReferences()
maps.Copy(allRefs, refs)
}
allRefs := context.Document.GetRolodex().GetAllReferences()
schemas := context.Index.GetAllComponentSchemas()
responses := context.Index.GetAllResponses()
parameters := context.Index.GetAllParameters()
Expand All @@ -54,12 +49,7 @@ func (uc UnusedComponent) RunRule(nodes []*yaml.Node, context model.RuleFunction
securitySchemes := context.Index.GetAllSecuritySchemes()
links := context.Index.GetAllLinks()
callbacks := context.Index.GetAllCallbacks()

mappedRefs := context.Document.GetRolodex().GetRootIndex().GetMappedReferences()
for _, idx := range context.Document.GetRolodex().GetIndexes() {
refs := idx.GetMappedReferences()
maps.Copy(mappedRefs, refs)
}
mappedRefs := context.Document.GetRolodex().GetAllMappedReferences()

// extract securityRequirements from swagger. These are not mapped as they are not $refs
// so, we need to map them as if they were.
Expand Down

0 comments on commit 440ff38

Please sign in to comment.