mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +00:00
some ref handling was a bit strange, now it's rendering correctly. I have a feeling we will be back to the diff engine at some point soon, it's picking up some strange changes that are so deep in the model, I can't determine what is what, so we will wait for another set of triggers to appear.
69 lines
1.3 KiB
Go
69 lines
1.3 KiB
Go
// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package utils
|
|
|
|
import "gopkg.in/yaml.v3"
|
|
|
|
func CreateRefNode(ref string) *yaml.Node {
|
|
m := CreateEmptyMapNode()
|
|
nodes := make([]*yaml.Node, 2)
|
|
nodes[0] = CreateStringNode("$ref")
|
|
nodes[1] = CreateStringNode(ref)
|
|
nodes[1].Style = yaml.SingleQuotedStyle
|
|
m.Content = nodes
|
|
return m
|
|
}
|
|
|
|
func CreateEmptyMapNode() *yaml.Node {
|
|
n := &yaml.Node{
|
|
Kind: yaml.MappingNode,
|
|
Tag: "!!map",
|
|
}
|
|
return n
|
|
}
|
|
|
|
func CreateEmptySequenceNode() *yaml.Node {
|
|
n := &yaml.Node{
|
|
Kind: yaml.SequenceNode,
|
|
Tag: "!!seq",
|
|
}
|
|
return n
|
|
}
|
|
|
|
func CreateStringNode(str string) *yaml.Node {
|
|
n := &yaml.Node{
|
|
Kind: yaml.ScalarNode,
|
|
Tag: "!!str",
|
|
Value: str,
|
|
}
|
|
return n
|
|
}
|
|
|
|
func CreateBoolNode(str string) *yaml.Node {
|
|
n := &yaml.Node{
|
|
Kind: yaml.ScalarNode,
|
|
Tag: "!!bool",
|
|
Value: str,
|
|
}
|
|
return n
|
|
}
|
|
|
|
func CreateIntNode(str string) *yaml.Node {
|
|
n := &yaml.Node{
|
|
Kind: yaml.ScalarNode,
|
|
Tag: "!!int",
|
|
Value: str,
|
|
}
|
|
return n
|
|
}
|
|
|
|
func CreateFloatNode(str string) *yaml.Node {
|
|
n := &yaml.Node{
|
|
Kind: yaml.ScalarNode,
|
|
Tag: "!!float",
|
|
Value: str,
|
|
}
|
|
return n
|
|
}
|