mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-07 12:37:48 +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
|
AllowRemoteLookup bool // Allow remote lookups for references. Defaults to false
|
||||||
AllowFileLookup bool // Allow file 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
|
seenRemoteSources *syncmap.Map
|
||||||
remoteLock *sync.Mutex
|
remoteLock *sync.Mutex
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,22 +142,7 @@ func (resolver *Resolver) Resolve() []*ResolvingError {
|
|||||||
|
|
||||||
// CheckForCircularReferences Check for circular references, without resolving, a non-destructive run.
|
// CheckForCircularReferences Check for circular references, without resolving, a non-destructive run.
|
||||||
func (resolver *Resolver) CheckForCircularReferences() []*ResolvingError {
|
func (resolver *Resolver) CheckForCircularReferences() []*ResolvingError {
|
||||||
mapped := resolver.specIndex.GetMappedReferencesSequenced()
|
visitIndex(resolver, resolver.specIndex)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, circRef := range resolver.circularReferences {
|
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
|
// 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