utils

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ParsedYAMLFiles map[string]*yaml.Node
View Source
var ResolvedRefs map[string]*yaml.Node

Functions

func AddEntryToOASYAML added in v0.1.15

func AddEntryToOASYAML(oas *yaml.Node, key string, value any, defaultVal *yaml.Node) (*yaml.Node, error)

func CopyFile

func CopyFile(dest string, src string) error

func DetectCycle added in v0.1.15

func DetectCycle(node *yaml.Node, filePath string) (bool, error)

func JSONFile2YAMLFile added in v0.1.15

func JSONFile2YAMLFile(input string, output string) error

func JSONPointer2JSONPath

func JSONPointer2JSONPath(jsonPointer string) (jsonPath string, err error)

func JSONText2YAMLText added in v0.1.15

func JSONText2YAMLText(reader io.Reader) ([]byte, error)

func LocateRef added in v0.1.15

func LocateRef(refFileNode *yaml.Node, refJSONPath string, jsonRef string) (*yaml.Node, error)

func MakeCyclicRefPlaceholder added in v0.1.15

func MakeCyclicRefPlaceholder(refJSONPath string) *yaml.Node

func Must

func Must(err error)

func MustClose

func MustClose(c io.Closer)

func MustReadFileBytes

func MustReadFileBytes(path string) []byte

func NewCyclicJSONRefError added in v0.1.15

func NewCyclicJSONRefError(paths []string) error

func OAS2FileToOAS3File added in v0.1.15

func OAS2FileToOAS3File(input string, output string, allowCycles bool) error

func OAS2ToYAML added in v0.1.15

func OAS2ToYAML(doc *openapi2.T) (*yaml.Node, error)

func OAS2YAMLtoOAS3YAML added in v0.1.15

func OAS2YAMLtoOAS3YAML(oasNode *yaml.Node) (*yaml.Node, error)

func OAS3FileToOAS2File added in v0.1.15

func OAS3FileToOAS2File(input string, output string, allowCycles bool) error

func OAS3ToYAML added in v0.1.15

func OAS3ToYAML(doc *openapi3.T) (*yaml.Node, error)

func OAS3YAMLtoOAS2YAML added in v0.1.15

func OAS3YAMLtoOAS2YAML(oasNode *yaml.Node) (*yaml.Node, error)

func ParseYAMLFile

func ParseYAMLFile(filePath string) (*yaml.Node, error)

func ReadInputText added in v0.1.15

func ReadInputText(input string) ([]byte, error)

func ResetYAMLRefs added in v0.1.15

func ResetYAMLRefs()

func ResolveCycles added in v0.1.15

func ResolveCycles(node *yaml.Node, filePath string) (*yaml.Node, error)

func ResolveDollarRefs added in v0.1.15

func ResolveDollarRefs(input string, output string, allowCycles bool) error

func ResolveYAMLRef

func ResolveYAMLRef(root *yaml.Node,
	node *yaml.Node, nodePath string, nodePaths []string,
	filePath string, filePaths []string,
	allowCycles bool, resolveCyclesOnly bool) (*yaml.Node, bool, error)

func ResolveYAMLRefs

func ResolveYAMLRefs(node *yaml.Node, filePath string, allowCycles bool) (*yaml.Node, error)

func ResolveYAMLRefsRecursive added in v0.1.15

func ResolveYAMLRefsRecursive(root *yaml.Node, node *yaml.Node,
	nodePath string, nodePaths []string,
	filePath string, filePaths []string,
	allowCycles bool,
	resolveCyclesOnly bool) (*yaml.Node, bool, error)

func RunWithinDirectory added in v0.1.15

func RunWithinDirectory[ResultType *yaml.Node](dir string, operation func() (ResultType, error)) (ResultType, error)

func SplitJSONRef

func SplitJSONRef(refStr string) (location string, jsonPath string, err error)

func Struct2XMLDocText

func Struct2XMLDocText(p any) ([]byte, error)

func Text2XML

func Text2XML(reader io.Reader) (*etree.Document, error)

func Text2YAML

func Text2YAML(reader io.Reader) (*yaml.Node, error)

func UnFlowYAMLNode added in v0.1.15

func UnFlowYAMLNode(node *yaml.Node) *yaml.Node

func WriteOutputText added in v0.1.15

func WriteOutputText(output string, outputText []byte) error

func XML2Text

func XML2Text(doc *etree.Document) ([]byte, error)

func XML2YAML

func XML2YAML(doc *etree.Document) (*yaml.Node, error)

func XML2YAMLRecursive

func XML2YAMLRecursive(ele *etree.Element) (key *yaml.Node, value *yaml.Node, err error)

func XML2YAMLText

func XML2YAMLText(doc *etree.Document, indent int) ([]byte, error)

func XMLFile2YAMLFile added in v0.1.15

func XMLFile2YAMLFile(input string, output string) error

func XMLText2XML

func XMLText2XML(reader io.Reader) (*etree.Document, error)

func XMLText2YAML

func XMLText2YAML(reader io.Reader) (*yaml.Node, error)

func XMLText2YAMLText

func XMLText2YAMLText(reader io.Reader) ([]byte, error)

func XMLTextFormat

func XMLTextFormat(reader io.Reader) ([]byte, error)

func YAML2Text

func YAML2Text(node *yaml.Node, indent int) ([]byte, error)

func YAML2XML

func YAML2XML(node *yaml.Node) (*etree.Document, error)

func YAML2XMLRecursive

func YAML2XMLRecursive(node *yaml.Node, parent *etree.Element) (*etree.Element, error)

func YAML2XMLText

func YAML2XMLText(node *yaml.Node) ([]byte, error)

func YAMLDoc2File

func YAMLDoc2File(docNode *yaml.Node, outputFile string) error

func YAMLFile2JSONFile added in v0.1.15

func YAMLFile2JSONFile(input string, output string) error

func YAMLFile2XMLFile added in v0.1.15

func YAMLFile2XMLFile(input string, output string) error

func YAMLFile2YAML

func YAMLFile2YAML(filePath string) (*yaml.Node, error)

func YAMLText2JSONText added in v0.1.15

func YAMLText2JSONText(reader io.Reader) ([]byte, error)

func YAMLText2XML

func YAMLText2XML(reader io.Reader) (*etree.Document, error)

func YAMLText2XMLText

func YAMLText2XMLText(reader io.Reader) ([]byte, error)

Types

type CyclicJSONRefError added in v0.1.15

type CyclicJSONRefError struct {
	Paths []string
}

func (CyclicJSONRefError) Error added in v0.1.15

func (e CyclicJSONRefError) Error() string

type StdoutCapture

type StdoutCapture struct {
	// contains filtered or unexported fields
}

func NewStdoutCapture

func NewStdoutCapture() (*StdoutCapture, error)

func (*StdoutCapture) Read

func (sf *StdoutCapture) Read() ([]byte, error)

func (*StdoutCapture) Restore

func (sf *StdoutCapture) Restore()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL