From 4d2262416435b1e5433779ca336e245792b36361 Mon Sep 17 00:00:00 2001 From: Thomas Rooney Date: Fri, 4 Oct 2024 14:14:43 +0100 Subject: [PATCH] fix: a parameter in the rolodex should be evaluated using the index that the node is in --- index/utility_methods.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/index/utility_methods.go b/index/utility_methods.go index 16c470ba..a6b2ca35 100644 --- a/index/utility_methods.go +++ b/index/utility_methods.go @@ -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, "%") { @@ -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) {