Updated index to count schemas, even if they are refs.

This was brought up in chat, that the expectation is that all schemas are included, refs or not. This update fixes that for the index and adds in a new individual property to count just the references `GetAllReferenceSchemas `

Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
Dave Shanley
2023-08-09 07:32:41 -04:00
committed by quobix
parent 832f3765c9
commit f7ab737f0a
5 changed files with 57 additions and 31 deletions

View File

@@ -43,6 +43,12 @@ func (index *SpecIndex) ExtractRefs(node, parent *yaml.Node, seenPath []string,
if i%2 == 0 && n.Value == "schema" && !utils.IsNodeArray(node) && (i+1 < len(node.Content)) {
isRef, _, _ := utils.IsNodeRefValue(node.Content[i+1])
if isRef {
// record this reference
ref := &Reference{
Node: node.Content[i+1],
Path: fmt.Sprintf("$.%s.schema", strings.Join(seenPath, ".")),
}
index.allRefSchemaDefinitions = append(index.allRefSchemaDefinitions, ref)
continue
}
ref := &Reference{