Properties named ‘enum’ were being indexed as enums

An edge case reported in https://github.com/daveshanley/vacuum/issues/339 shows up when enums are being indexed when they are actually a property of a schema called ‘enum’.

This has been fixed.

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2023-09-16 09:36:07 -04:00
parent 86f5f3e7cd
commit fcc12cb7dc
2 changed files with 43 additions and 0 deletions

View File

@@ -329,6 +329,11 @@ func (index *SpecIndex) ExtractRefs(node, parent *yaml.Node, seenPath []string,
// capture enums
if n.Value == "enum" {
lastItem := seenPath[len(seenPath)-1]
if lastItem == "properties" {
continue
}
// all enums need to have a type, extract the type from the node where the enum was found.
_, enumKeyValueNode := utils.FindKeyNodeTop("type", node.Content)