Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrIllegalToken = errors.New("illegal token")
ErrIllegalToken is returned when a token is used that is not expected, e.g. two indexOpen tokens [[ sequentially
Functions ¶
func LintBytes ¶
LintBytes is a utility method that unmarshaled the provided bytes into a yaml.Node, applies Lint on the node and returns the marshaled result
func StringOrderingFn ¶
StringOrderingFn sorts yaml.MappingNode and yaml.SequenceNode on their yaml.Node.Value using default cmp.Compare function
Types ¶
type OrderFn ¶
OrderFn is executed on some yaml.Node with the key being a JSONPath like value
func NewSimpleOrdering ¶
NewSimpleOrdering sorts the keys of a yaml.MappingNode in the order provided with "keys". If keys that are present in the YAML are not present in the supplied keys, the original order of that key will be preserved after all supplied keys are processed. e.g. NewSimpleOrdering("a", "b", "c") on a yaml node with keys ["c", "f", "b", "e", "a"] will result in ["a", "b", "c", "f", "e"] (notice how a, b, c are at the front in order provided and remaining keys are in their original order)
type Rule ¶
type Rule struct {
// Path using a JSONPath like syntax (except filtering):
// '$' is the document root
// '$.key' to select a key
// '$[0]' to select some index
// '$[*]' or '$.*' for wildcard searches
// '$.some[*].*.name' can combine any of above rules
Path string
// Functions to execute if there is a Path match
Functions []OrderFn
}
Rule combines a JSONPath like syntax to an OrderFn to apply on the node
func DefaultOpenAPIRules ¶
func DefaultOpenAPIRules() []Rule
DefaultOpenAPIRules contains an opinionated ordering of an 'openapi.yaml' file based on the tables documented on https://swagger.io/specification/#schema-1