mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +00:00
(feat): Added Reference tracking to low-level model #25
When building a document, everything that IS NOT a schema is auto-resolved in the model, this is very convenient because it creates a nice tree to explore and there is no need to perform lookups to when using `$ref` instead of inline definitions. The issue is however being able to determine if the node was originally a reference or not, that data was lost, including the name of the reference used. This use case surfaced in issue #25, where the need to know what is and what is not referenced has different requirements for different applications. This update now tracks that data and makes it available in `NodeReference` and `ValueReference` for every property. Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
@@ -48,7 +48,7 @@ func (cb *Callback) Build(root *yaml.Node, idx *index.SpecIndex) error {
|
||||
currentCB = callbackNode
|
||||
continue
|
||||
}
|
||||
callback, eErr := low.ExtractObjectRaw[*PathItem](callbackNode, idx)
|
||||
callback, eErr, isRef, rv := low.ExtractObjectRaw[*PathItem](callbackNode, idx)
|
||||
if eErr != nil {
|
||||
return eErr
|
||||
}
|
||||
@@ -56,8 +56,10 @@ func (cb *Callback) Build(root *yaml.Node, idx *index.SpecIndex) error {
|
||||
Value: currentCB.Value,
|
||||
KeyNode: currentCB,
|
||||
}] = low.ValueReference[*PathItem]{
|
||||
Value: callback,
|
||||
ValueNode: callbackNode,
|
||||
Value: callback,
|
||||
ValueNode: callbackNode,
|
||||
IsReference: isRef,
|
||||
Reference: rv,
|
||||
}
|
||||
}
|
||||
if len(callbacks) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user