diff --git a/datamodel/low/base/schema.go b/datamodel/low/base/schema.go index 2d58fc0..536be2b 100644 --- a/datamodel/low/base/schema.go +++ b/datamodel/low/base/schema.go @@ -1221,6 +1221,15 @@ func ExtractSchema(ctx context.Context, root *yaml.Node, idx *index.SpecIndex) ( if schNode != nil { h := false if h, _, refLocation = utils.IsNodeRefValue(schNode); h { + var specPath string + if ctx != nil && ctx.Value(index.CurrentPathKey) != nil { + specPath = ctx.Value(index.CurrentPathKey).(string) + } + if idx.GetSpecAbsolutePath() != specPath && (!strings.HasPrefix(refLocation, "http") && + !strings.HasPrefix(idx.GetSpecAbsolutePath(), "http")) { + ctx = context.WithValue(ctx, index.CurrentPathKey, idx.GetSpecAbsolutePath()) + } + ref, _, _, nCtx := low.LocateRefNodeWithContext(ctx, schNode, idx) if ref != nil { refNode = schNode diff --git a/index/search_index.go b/index/search_index.go index 06723e3..524f97c 100644 --- a/index/search_index.go +++ b/index/search_index.go @@ -149,10 +149,10 @@ func (index *SpecIndex) SearchIndexForReferenceByReferenceWithContext(ctx contex Definition: n, IsRemote: true, RemoteLocation: n, - Index: index, + Index: rFile.GetIndex(), Node: node.Content[0], ParentNode: node, - }, index, ctx + }, rFile.GetIndex(), ctx } else { return nil, index, ctx }