mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-07 20:47:45 +00:00
High-level base documentation is complete.
Examples and every model completed, 1/6th of the way through models.
This commit is contained in:
36
datamodel/high/base/xml_test.go
Normal file
36
datamodel/high/base/xml_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package base
|
||||
|
||||
import (
|
||||
"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 := `
|
||||
namespace: https://pb33f.io/schema
|
||||
prefix: sample`
|
||||
|
||||
// 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 the high level tag
|
||||
highXML := NewXML(&lowXML)
|
||||
|
||||
// print out the XML namespace
|
||||
fmt.Print(highXML.Namespace)
|
||||
// Output: https://pb33f.io/schema
|
||||
}
|
||||
Reference in New Issue
Block a user