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 Aug 28, 2024
1 parent 7e0917d commit caaa08c
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()

Check failure on line 42 in functions/openapi/unused_component.go

View workflow job for this annotation

GitHub Actions / Build

context.Document.GetRolodex().GetAllReferences undefined (type *index.Rolodex has no field or method 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()

Check failure on line 52 in functions/openapi/unused_component.go

View workflow job for this annotation

GitHub Actions / Build

context.Document.GetRolodex().GetAllMappedReferences undefined (type *index.Rolodex has no field or method 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 caaa08c

Please sign in to comment.