From cd63f66efe06596c72589b1fb8c37774b4f18341 Mon Sep 17 00:00:00 2001 From: "Benjamin Nolan (TwoWholeWorms)" Date: Sat, 7 Jan 2023 08:53:53 +0100 Subject: [PATCH] fix: Check for direct reference in IsPropertyNodeRequired --- index/spec_index.go | 2 +- utils/utils.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/index/spec_index.go b/index/spec_index.go index f06682d..d125f88 100644 --- a/index/spec_index.go +++ b/index/spec_index.go @@ -1721,7 +1721,7 @@ func (index *SpecIndex) extractDefinitionRequiredRefProperties(schemaNode *yaml. return reqRefProps } - // If the path we're looking at is a direct ref to another model without any properties, mark it as required, but still continue to look for required properties + // If the node we're looking at is a direct ref to another model without any properties, mark it as required, but still continue to look for required properties isRef, _, defPath := utils.IsNodeRefValue(schemaNode) if isRef { if _, ok := reqRefProps[defPath]; !ok { diff --git a/utils/utils.go b/utils/utils.go index 312ffe4..acf8be2 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -405,6 +405,12 @@ func IsNodeRefValue(node *yaml.Node) (bool, *yaml.Node, string) { // IsPropertyNodeRequired will check if a node is required within circular references func IsPropertyNodeRequired(node *yaml.Node, propertyName string) bool { + // If the node we're looking at is a direct ref to another model without any properties, mark it as required + isRef, _, _ := IsNodeRefValue(node) + if isRef { + return true + } + _, requiredSeqNode := FindKeyNodeTop("required", node.Content) if requiredSeqNode == nil { return false