mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 04:20:17 +00:00
fix for resolving looping relative references
In vacuum, a usecase was reported where an infinite loop occurred due to re-parsing the same reference over and over in a loop. It was re-creatable and it was because the loop happened before the index was ready. This should be resolved now, at least for this use case. To be sure, I have included the specs as a new test. https://github.com/daveshanley/vacuum/issues/268 Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
@@ -32,6 +32,8 @@ func NewSpecIndexWithConfig(rootNode *yaml.Node, config *SpecIndexConfig) *SpecI
|
||||
}
|
||||
config.remoteLock = &sync.Mutex{}
|
||||
index.config = config
|
||||
index.parentIndex = config.ParentIndex
|
||||
index.uri = config.uri
|
||||
if rootNode == nil || len(rootNode.Content) <= 0 {
|
||||
return index
|
||||
}
|
||||
@@ -47,7 +49,7 @@ func NewSpecIndexWithConfig(rootNode *yaml.Node, config *SpecIndexConfig) *SpecI
|
||||
// defaults to allowing remote references and file references. This is a potential security risk and should be controlled by
|
||||
// providing a SpecIndexConfig that explicitly sets the AllowRemoteLookup and AllowFileLookup to true.
|
||||
// This function also does not support specifications with relative references that may not exist locally.
|
||||
// - https://github.com/pb33f/libopenapi/issues/73
|
||||
// - https://github.com/pb33f/libopenapi/issues/73
|
||||
func NewSpecIndex(rootNode *yaml.Node) *SpecIndex {
|
||||
index := new(SpecIndex)
|
||||
index.config = CreateOpenAPIIndexConfig()
|
||||
|
||||
Reference in New Issue
Block a user