Expose Key node on Low schema proxy

This commit is contained in:
Dmitry
2023-08-25 10:37:28 +02:00
committed by quobix
parent d185205ec9
commit ce1be302ee

View File

@@ -54,10 +54,12 @@ type SchemaProxy struct {
} }
// Build will prepare the SchemaProxy for rendering, it does not build the Schema, only sets up internal state. // Build will prepare the SchemaProxy for rendering, it does not build the Schema, only sets up internal state.
func (sp *SchemaProxy) Build(root *yaml.Node, idx *index.SpecIndex) error { // Key maybe nil if absent.
sp.vn = root func (sp *SchemaProxy) Build(key, value *yaml.Node, idx *index.SpecIndex) error {
sp.kn = key
sp.vn = value
sp.idx = idx sp.idx = idx
if rf, _, r := utils.IsNodeRefValue(root); rf { if rf, _, r := utils.IsNodeRefValue(value); rf {
sp.isReference = true sp.isReference = true
sp.referenceLookup = r sp.referenceLookup = r
} }
@@ -127,6 +129,11 @@ func (sp *SchemaProxy) GetSchemaReference() string {
return sp.referenceLookup return sp.referenceLookup
} }
// GetKeyNode will return the yaml.Node pointer that is a key for value node.
func (sp *SchemaProxy) GetKeyNode() *yaml.Node {
return sp.kn
}
// GetValueNode will return the yaml.Node pointer used by the proxy to generate the Schema. // GetValueNode will return the yaml.Node pointer used by the proxy to generate the Schema.
func (sp *SchemaProxy) GetValueNode() *yaml.Node { func (sp *SchemaProxy) GetValueNode() *yaml.Node {
return sp.vn return sp.vn