overlay

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(path string) error

Format will validate reformat the given file

Types

type Action

type Action struct {
	Extensions `yaml:"-,inline"`

	// Target is the JSONPath to the target of the action.
	Target string `yaml:"target"`

	// Description is a description of the action.
	Description string `yaml:"description,omitempty"`

	// Update is the sub-document to use to merge or replace in the target. This is
	// ignored if Remove is set.
	Update yaml.Node `yaml:"update,omitempty"`

	// Remove marks the target node for removal rather than update.
	Remove bool `yaml:"remove,omitempty"`
}

type Extensions

type Extensions map[string]any

Extensible provides a place for extensions to be added to components of the Overlay configuration. These are a map from x-* extension fields to their values.

type Info

type Info struct {
	Extensions `yaml:"-,inline"`

	// Title is the title of the overlay.
	Title string `yaml:"title"`

	// Version is the version of the overlay.
	Version string `yaml:"version"`
}

Info describes the metadata for the overlay.

type Overlay

type Overlay struct {
	Extensions Extensions `yaml:",inline"`

	// Version is the version of the overlay configuration.
	Version string `yaml:"overlay"`

	// JSONPathVersion should be set to rfc9535, and is used for backwards compatability purposes
	JSONPathVersion string `yaml:"x-speakeasy-jsonpath,omitempty"`

	// Info describes the metadata for the overlay.
	Info Info `yaml:"info"`

	// Extends is a URL to the OpenAPI specification this overlay applies to.
	Extends string `yaml:"extends,omitempty"`

	// Actions is the list of actions to perform to apply the overlay.
	Actions []Action `yaml:"actions"`
}

Overlay is the top-level configuration for an OpenAPI overlay.

func Compare

func Compare(title string, y1 *yaml.Node, y2 yaml.Node) (*Overlay, error)

Compare compares input specifications from two files and returns an overlay that will convert the first into the second.

func Parse

func Parse(path string) (*Overlay, error)

Parse will parse the given reader as an overlay file.

func (*Overlay) ApplyTo

func (o *Overlay) ApplyTo(root *yaml.Node) error

ApplyTo will take an overlay and apply its changes to the given YAML document.

func (*Overlay) Format

func (o *Overlay) Format(w io.Writer) error

Format writes the file back out as YAML.

func (*Overlay) ToString

func (o *Overlay) ToString() (string, error)

func (*Overlay) Validate

func (o *Overlay) Validate() error

type ValidationErrors

type ValidationErrors []error

func (ValidationErrors) Error

func (v ValidationErrors) Error() string

func (ValidationErrors) Return

func (v ValidationErrors) Return() error

Jump to

Keyboard shortcuts

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