Skip to content

Commit

Permalink
fix: a parameter in the rolodex should be evaluated using the index t…
Browse files Browse the repository at this point in the history
…hat the node is in
  • Loading branch information
ThomasRooney committed Oct 4, 2024
1 parent 4d074c3 commit 4d22624
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion index/utility_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ func (index *SpecIndex) scanOperationParams(params []*yaml.Node, keyNode, pathIt
paramRef := index.allMappedRefs[paramRefName]
if paramRef == nil {
// could be in the rolodex
ref := seekRefEnd(index, paramRefName)
searchInIndex := findIndex(index, param.Content[1])
ref := seekRefEnd(searchInIndex, paramRefName)
if ref != nil {
paramRef = ref
if strings.Contains(paramRefName, "%") {
Expand Down Expand Up @@ -510,6 +511,25 @@ func (index *SpecIndex) scanOperationParams(params []*yaml.Node, keyNode, pathIt
}
}

func findIndex(index *SpecIndex, i *yaml.Node) *SpecIndex {
allIndexes := index.GetRolodex().GetIndexes()
for _, searchIndex := range allIndexes {
nodeMap := searchIndex.GetNodeMap()
line, ok := nodeMap[i.Line]
if !ok {
continue
}
node, ok := line[i.Column]
if !ok {
continue
}
if node == i {
return searchIndex
}
}
return index
}

func runIndexFunction(funcs []func() int, wg *sync.WaitGroup) {
for _, cFunc := range funcs {
go func(wg *sync.WaitGroup, cf func() int) {
Expand Down

0 comments on commit 4d22624

Please sign in to comment.