Documentation
¶
Overview ¶
Package oasdoc edits an OpenAPI document as a YAML node tree, addressed by JSON pointers.
Index ¶
- Variables
- func Child(n *yaml.Node, key string) *yaml.Node
- func Clone(n *yaml.Node) *yaml.Node
- func DeleteChild(n *yaml.Node, key string) bool
- func DeleteChildren(n *yaml.Node, drop func(key string, value *yaml.Node) bool) bool
- func Escape(token string) string
- func NewMapping() *yaml.Node
- func NewString(value string) *yaml.Node
- func SetChild(n *yaml.Node, key string, value *yaml.Node)
- func Split(ptr string) ([]string, error)
- func Unescape(token string) string
- func UnescapeSlashes(data []byte) []byte
- func Visit(n *yaml.Node, ptr string, k Kind, ...)
- type Doc
- func (d *Doc) CopyLayout(from *Doc)
- func (d *Doc) Delete(ptr string) bool
- func (d *Doc) File() string
- func (d *Doc) Get(ptr string) *yaml.Node
- func (d *Doc) Marshal() ([]byte, error)
- func (d *Doc) Positions() map[string]diag.Origin
- func (d *Doc) Refs() []Ref
- func (d *Doc) Root() *yaml.Node
- func (d *Doc) Set(ptr string, value *yaml.Node) error
- func (d *Doc) SetFile(n *yaml.Node, file string)
- func (d *Doc) Version() (spec.Version, error)
- func (d *Doc) Walk(fn func(ptr string, n *yaml.Node) bool)
- type Kind
- type Ref
Constants ¶
This section is empty.
Variables ¶
var ( ErrParse = errors.New("parse spec") ErrNotObject = errors.New("spec root is not an object") ErrManyDocuments = errors.New("spec holds more than one YAML document") ErrUnsupportedVersion = errors.New("unsupported OpenAPI version") ErrPointer = errors.New("invalid JSON pointer") ErrNotFound = errors.New("JSON pointer not found") ErrMarshal = errors.New("marshal spec") )
Functions ¶
func Clone ¶
Clone copies n deeply, keeping lines and columns. An alias becomes a copy of its target.
func DeleteChild ¶
DeleteChild removes key from mapping n and reports whether it was there.
func DeleteChildren ¶
DeleteChildren removes, in one pass, every entry of mapping n that drop picks, and reports whether it removed any.
func NewMapping ¶
func Split ¶
Split turns a pointer into unescaped tokens; a # prefix marks a $ref fragment, also percent-decoded.
func UnescapeSlashes ¶
UnescapeSlashes turns \/ in a JSON spec into /: YAML 1.2 allows it, the YAML parser does not.
Types ¶
type Doc ¶
type Doc struct {
// contains filtered or unexported fields
}
Doc is a parsed spec. JSON input is read as YAML and written back as block YAML.
func (*Doc) CopyLayout ¶
CopyLayout makes d marshal with the indentation and sequence style of from.
func (*Doc) Delete ¶
Delete removes the node at ptr and reports whether there was one. The root cannot be deleted.
func (*Doc) Marshal ¶
Marshal keeps the source indentation; the encoder rewrites scalar tags and quotes in place.
func (*Doc) Positions ¶
Positions maps the pointer of every node to where it starts. A mapping entry starts at its key, unless its value came from another file. Nodes made in memory have no line and are left out, so lookups fall back to an ancestor.
func (*Doc) Set ¶
Set puts value at ptr. A missing last key is added to its mapping; "-" appends to a sequence.
type Kind ¶
type Kind int
Kind is the OpenAPI object a node stands for, known from where it sits.
func SectionKind ¶
SectionKind is the kind of the objects under components/section, or KindNone.