Fixed a low level bug with locating nodes.

locating nodes was looking through two levels to locate something. This is not the correct behavior, after making the change - lots of tests needed to be updated to be correct in what they put into as a the root node.
This commit is contained in:
Dave Shanley
2022-11-04 09:50:20 -04:00
parent 131513a6f6
commit a184c5e909
34 changed files with 220 additions and 161 deletions

View File

@@ -4,33 +4,33 @@
package base
import (
"fmt"
lowmodel "github.com/pb33f/libopenapi/datamodel/low"
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
"gopkg.in/yaml.v3"
"fmt"
lowmodel "github.com/pb33f/libopenapi/datamodel/low"
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
"gopkg.in/yaml.v3"
)
func ExampleNewXML() {
// create an example schema object
// this can be either JSON or YAML.
yml := `
// create an example schema object
// this can be either JSON or YAML.
yml := `
namespace: https://pb33f.io/schema
prefix: sample`
// unmarshal raw bytes
var node yaml.Node
_ = yaml.Unmarshal([]byte(yml), &node)
// unmarshal raw bytes
var node yaml.Node
_ = yaml.Unmarshal([]byte(yml), &node)
// build out the low-level model
var lowXML lowbase.XML
_ = lowmodel.BuildModel(&node, &lowXML)
_ = lowXML.Build(node.Content[0], nil)
// build out the low-level model
var lowXML lowbase.XML
_ = lowmodel.BuildModel(node.Content[0], &lowXML)
_ = lowXML.Build(node.Content[0], nil)
// build the high level tag
highXML := NewXML(&lowXML)
// build the high level tag
highXML := NewXML(&lowXML)
// print out the XML namespace
fmt.Print(highXML.Namespace)
// Output: https://pb33f.io/schema
// print out the XML namespace
fmt.Print(highXML.Namespace)
// Output: https://pb33f.io/schema
}