Documentation ¶
Index ¶
- Variables
- func AreValuesCorrectlyTyped(valType string, values interface{}) map[string]string
- func BuildPath(basePath string, segs []string) string
- func CheckEnumForDuplicates(seq []*yaml.Node) []*yaml.Node
- func CheckForMergeNodes(node *yaml.Node)
- func CheckPathOverlap(pathA, pathB, sep string) string
- func ConvertComponentIdIntoFriendlyPathSearch(id string) (string, string)
- func ConvertComponentIdIntoPath(id string) (string, string)
- func ConvertInterfaceArrayToStringArray(raw interface{}) []string
- func ConvertInterfaceIntoStringMap(context interface{}) map[string]string
- func ConvertInterfaceToStringArray(raw interface{}) []string
- func ConvertYAMLtoJSON(yamlData []byte) ([]byte, error)
- func CreateBoolNode(str string) *yaml.Node
- func CreateEmptyMapNode() *yaml.Node
- func CreateEmptyScalarNode() *yaml.Node
- func CreateEmptySequenceNode() *yaml.Node
- func CreateFloatNode(str string) *yaml.Node
- func CreateIntNode(str string) *yaml.Node
- func CreateRefNode(ref string) *yaml.Node
- func CreateStringNode(str string) *yaml.Node
- func CreateYamlNode(a any) *yaml.Node
- func DetermineWhitespaceLength(input string) int
- func ExtractValueFromInterfaceMap(name string, raw interface{}) interface{}
- func FindFirstKeyNode(key string, nodes []*yaml.Node, depth int) (keyNode *yaml.Node, valueNode *yaml.Node)
- func FindKeyNode(key string, nodes []*yaml.Node) (keyNode *yaml.Node, valueNode *yaml.Node)
- func FindKeyNodeFull(key string, nodes []*yaml.Node) (keyNode *yaml.Node, labelNode *yaml.Node, valueNode *yaml.Node)
- func FindKeyNodeFullTop(key string, nodes []*yaml.Node) (keyNode *yaml.Node, labelNode *yaml.Node, valueNode *yaml.Node)
- func FindKeyNodeTop(key string, nodes []*yaml.Node) (keyNode *yaml.Node, valueNode *yaml.Node)
- func FindLastChildNode(node *yaml.Node) *yaml.Node
- func FindLastChildNodeWithLevel(node *yaml.Node, level int) *yaml.Node
- func FindNodes(yamlData []byte, jsonPath string) ([]*yaml.Node, error)
- func FindNodesWithoutDeserializing(node *yaml.Node, jsonPath string) ([]*yaml.Node, error)
- func FixContext(context string) string
- func IsHttpVerb(verb string) bool
- func IsJSON(testString string) bool
- func IsNodeAlias(node *yaml.Node) (*yaml.Node, bool)
- func IsNodeArray(node *yaml.Node) bool
- func IsNodeBoolValue(node *yaml.Node) bool
- func IsNodeFloatValue(node *yaml.Node) bool
- func IsNodeIntValue(node *yaml.Node) bool
- func IsNodeMap(node *yaml.Node) bool
- func IsNodeNumberValue(node *yaml.Node) bool
- func IsNodePolyMorphic(node *yaml.Node) bool
- func IsNodeRefValue(node *yaml.Node) (bool, *yaml.Node, string)
- func IsNodeStringValue(node *yaml.Node) bool
- func IsYAML(testString string) bool
- func MakeTagReadable(node *yaml.Node) string
- func NodeAlias(node *yaml.Node) *yaml.Node
- func NodeMerge(nodes []*yaml.Node) *yaml.Node
- func RenderCodeSnippet(startNode *yaml.Node, specData []string, before, after int) string
- func ReplaceWindowsDriveWithLinuxPath(path string) string
- func UnwrapErrors(err error) []error
- type Case
- type ExtensionNode
- type KeyNodeResult
- type KeyNodeSearch
- type RemoteURLHandler
Constants ¶
This section is empty.
Variables ¶
var ( ObjectLabel = "object" IntegerLabel = "integer" NumberLabel = "number" StringLabel = "string" BinaryLabel = "binary" ArrayLabel = "array" BooleanLabel = "boolean" SchemaSource = "https://json-schema.org/draft/2020-12/schema" SchemaId = "https://pb33f.io/openapi-changes/schema" )
Functions ¶
func AreValuesCorrectlyTyped ¶ added in v0.0.8
AreValuesCorrectlyTyped will look through an array of unknown values and check they match against the supplied type as a string. The return value is empty if everything is OK, or it contains failures in the form of a value as a key and a message as to why it's not valid
func CheckEnumForDuplicates ¶ added in v0.0.8
func CheckEnumForDuplicates(seq []*yaml.Node) []*yaml.Node
CheckEnumForDuplicates will check an array of nodes to check if there are any duplicate values.
func CheckForMergeNodes ¶ added in v0.9.3
func CheckForMergeNodes(node *yaml.Node)
CheckForMergeNodes will check the top level of the schema for merge nodes. If any are found, then the merged nodes will be appended to the end of the rest of the nodes in the schema. Note: this is a destructive operation, so the in-memory node structure will be modified
func CheckPathOverlap ¶ added in v0.15.0
func ConvertComponentIdIntoFriendlyPathSearch ¶
ConvertComponentIdIntoFriendlyPathSearch will convert a JSON Path into a friendly path search string. the friendliness comes from it being suitable for use with any JSON Path parser.
This function was re-written in v0.18.0 in order to fix a number of performance issues with the original implementation. Allocations were high and this function is used a lot, this new implementation is much lighter on string allocations by using a string builder.
func ConvertComponentIdIntoPath ¶
ConvertComponentIdIntoPath will convert a JSON Path into a component ID TODO: This function is named incorrectly and should be changed to reflect the correct function
func ConvertInterfaceArrayToStringArray ¶
func ConvertInterfaceArrayToStringArray(raw interface{}) []string
ConvertInterfaceArrayToStringArray will convert an unknown interface array type, into a string slice
func ConvertInterfaceIntoStringMap ¶
ConvertInterfaceIntoStringMap will convert an unknown input into a string map.
func ConvertInterfaceToStringArray ¶
func ConvertInterfaceToStringArray(raw interface{}) []string
ConvertInterfaceToStringArray will convert an unknown input map type into a string array/slice
func ConvertYAMLtoJSON ¶
ConvertYAMLtoJSON will do exactly what you think it will. It will deserialize YAML into serialized JSON.
func CreateBoolNode ¶ added in v0.7.0
func CreateBoolNode(str string) *yaml.Node
func CreateEmptyMapNode ¶ added in v0.7.0
func CreateEmptyMapNode() *yaml.Node
func CreateEmptyScalarNode ¶ added in v0.16.9
func CreateEmptyScalarNode() *yaml.Node
func CreateEmptySequenceNode ¶ added in v0.7.0
func CreateEmptySequenceNode() *yaml.Node
func CreateFloatNode ¶ added in v0.7.0
func CreateFloatNode(str string) *yaml.Node
func CreateIntNode ¶ added in v0.7.0
func CreateIntNode(str string) *yaml.Node
func CreateRefNode ¶ added in v0.7.0
func CreateRefNode(ref string) *yaml.Node
func CreateStringNode ¶ added in v0.7.0
func CreateStringNode(str string) *yaml.Node
func CreateYamlNode ¶ added in v0.14.0
func CreateYamlNode(a any) *yaml.Node
func DetermineWhitespaceLength ¶ added in v0.9.0
DetermineWhitespaceLength will determine the length of the whitespace for a JSON or YAML file.
func ExtractValueFromInterfaceMap ¶
func ExtractValueFromInterfaceMap(name string, raw interface{}) interface{}
ExtractValueFromInterfaceMap pulls out an unknown value from a map using a string key
func FindFirstKeyNode ¶
func FindFirstKeyNode(key string, nodes []*yaml.Node, depth int) (keyNode *yaml.Node, valueNode *yaml.Node)
FindFirstKeyNode will locate the first key and value yaml.Node based on a key.
func FindKeyNode ¶
func FindKeyNode(key string, nodes []*yaml.Node) (keyNode *yaml.Node, valueNode *yaml.Node)
FindKeyNode is a non-recursive search of a *yaml.Node Content for a child node with a key. Returns the key and value
func FindKeyNodeFull ¶ added in v0.0.5
func FindKeyNodeFull(key string, nodes []*yaml.Node) (keyNode *yaml.Node, labelNode *yaml.Node, valueNode *yaml.Node)
FindKeyNodeFull is an overloaded version of FindKeyNode. This version however returns keys, labels and values. generally different things are required from different node trees, so depending on what this function is looking at it will return different things.
func FindKeyNodeFullTop ¶ added in v0.1.4
func FindKeyNodeFullTop(key string, nodes []*yaml.Node) (keyNode *yaml.Node, labelNode *yaml.Node, valueNode *yaml.Node)
FindKeyNodeFullTop is an overloaded version of FindKeyNodeFull. This version only looks at the top level of the node and not the children.
func FindKeyNodeTop ¶
func FindKeyNodeTop(key string, nodes []*yaml.Node) (keyNode *yaml.Node, valueNode *yaml.Node)
FindKeyNodeTop is a non-recursive search of top level nodes for a key, will not look at content. Returns the key and value
func FindLastChildNode ¶
func FindLastChildNode(node *yaml.Node) *yaml.Node
FindLastChildNode will find the last node in a tree, based on a starting node. Deprecated: This function is deprecated, use FindLastChildNodeWithLevel instead. this has the potential to cause a stack overflow, so use with caution. It will be removed later.
func FindLastChildNodeWithLevel ¶ added in v0.8.1
func FindLastChildNodeWithLevel(node *yaml.Node, level int) *yaml.Node
FindLastChildNodeWithLevel will find the last node in a tree, based on a starting node. Will stop searching after 100 levels, because that's just silly, we probably have a loop.
func FindNodesWithoutDeserializing ¶
FindNodesWithoutDeserializing will find a node based on JSONPath, without deserializing from yaml/json
func FixContext ¶
FixContext will clean up a JSONpath string to be correctly traversable.
func IsHttpVerb ¶
IsHttpVerb will check if an operation is valid or not.
func IsNodeAlias ¶ added in v0.9.3
func IsNodeAlias(node *yaml.Node) (*yaml.Node, bool)
IsNodeAlias checks if the node is an alias, and lifts out the anchor
func IsNodeArray ¶
func IsNodeArray(node *yaml.Node) bool
IsNodeArray checks if a node is an array type
func IsNodeBoolValue ¶
func IsNodeBoolValue(node *yaml.Node) bool
IsNodeBoolValue will check is a node is a bool
func IsNodeFloatValue ¶
func IsNodeFloatValue(node *yaml.Node) bool
IsNodeFloatValue will check is a node is a float value.
func IsNodeIntValue ¶
func IsNodeIntValue(node *yaml.Node) bool
IsNodeIntValue will check if a node is an int value
func IsNodeNumberValue ¶ added in v0.9.0
func IsNodeNumberValue(node *yaml.Node) bool
IsNodeNumberValue will check if a node can be parsed as a float value.
func IsNodePolyMorphic ¶
func IsNodePolyMorphic(node *yaml.Node) bool
IsNodePolyMorphic will return true if the node contains polymorphic keys.
func IsNodeRefValue ¶ added in v0.0.5
func IsNodeStringValue ¶
func IsNodeStringValue(node *yaml.Node) bool
IsNodeStringValue checks if a node is a string value
func MakeTagReadable ¶
func MakeTagReadable(node *yaml.Node) string
func NodeAlias ¶ added in v0.9.3
func NodeAlias(node *yaml.Node) *yaml.Node
NodeAlias checks if the node is an alias, and lifts out the anchor
func RenderCodeSnippet ¶
func ReplaceWindowsDriveWithLinuxPath ¶ added in v0.15.0
func UnwrapErrors ¶ added in v0.13.0
Types ¶
type Case ¶ added in v0.0.5
type Case int8
const ( // OpenApi3 is used by all OpenAPI 3+ docs OpenApi3 = "openapi" // OpenApi2 is used by all OpenAPI 2 docs, formerly known as swagger. OpenApi2 = "swagger" // AsyncApi is used by akk AsyncAPI docs, all versions. AsyncApi = "asyncapi" PascalCase Case = iota CamelCase ScreamingSnakeCase SnakeCase KebabCase ScreamingKebabCase RegularCase UnknownCase )
func DetectCase ¶ added in v0.0.5
type ExtensionNode ¶ added in v0.0.5
type ExtensionNode struct { Key *yaml.Node Value *yaml.Node }
func FindExtensionNodes ¶ added in v0.0.5
func FindExtensionNodes(nodes []*yaml.Node) []*ExtensionNode
type KeyNodeResult ¶
type KeyNodeResult struct { KeyNode *yaml.Node ValueNode *yaml.Node Parent *yaml.Node Path []yaml.Node }
KeyNodeResult is a result from a KeyNodeSearch performed by the FindAllKeyNodesWithPath
type KeyNodeSearch ¶
type KeyNodeSearch struct { Key string Ignore []string Results []*KeyNodeResult AllowExtensions bool }
KeyNodeSearch keeps a track of everything we have found on our adventure down the trees.