mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +00:00
Aligned CheckForCircularErrors and Resolve
the two methods were doing different things, now they are not.
This commit is contained in:
@@ -68,11 +68,8 @@ type SpecIndexConfig struct {
|
||||
AllowRemoteLookup bool // Allow remote lookups for references. Defaults to false
|
||||
AllowFileLookup bool // Allow file lookups for references. Defaults to false
|
||||
|
||||
// Indexes can be deeply nested, depending on how complex each spec is. If creating a sub-index
|
||||
// this will help lookups remain efficient.
|
||||
RootIndex *SpecIndex // if this is a sub-index, the root knows about everything below.
|
||||
ParentIndex *SpecIndex // Who owns this index?
|
||||
|
||||
// private fields
|
||||
seenRemoteSources *syncmap.Map
|
||||
remoteLock *sync.Mutex
|
||||
}
|
||||
|
||||
@@ -142,22 +142,7 @@ func (resolver *Resolver) Resolve() []*ResolvingError {
|
||||
|
||||
// CheckForCircularReferences Check for circular references, without resolving, a non-destructive run.
|
||||
func (resolver *Resolver) CheckForCircularReferences() []*ResolvingError {
|
||||
mapped := resolver.specIndex.GetMappedReferencesSequenced()
|
||||
mappedIndex := resolver.specIndex.GetMappedReferences()
|
||||
for _, ref := range mapped {
|
||||
seenReferences := make(map[string]bool)
|
||||
var journey []*index.Reference
|
||||
resolver.VisitReference(ref.Reference, seenReferences, journey, false)
|
||||
}
|
||||
|
||||
schemas := resolver.specIndex.GetAllComponentSchemas()
|
||||
for s, schemaRef := range schemas {
|
||||
if mappedIndex[s] == nil {
|
||||
seenReferences := make(map[string]bool)
|
||||
var journey []*index.Reference
|
||||
resolver.VisitReference(schemaRef, seenReferences, journey, false)
|
||||
}
|
||||
}
|
||||
visitIndex(resolver, resolver.specIndex)
|
||||
|
||||
for _, circRef := range resolver.circularReferences {
|
||||
// If the circular reference is not required, we can ignore it, as it's a terminable loop rather than an infinite one
|
||||
|
||||
Reference in New Issue
Block a user