Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMultiDocument = errors.New("multi-document YAML not supported for OpenAPI specs") ErrNoDocument = errors.New("YAML has no documents") ErrNotMapping = errors.New("document root is not a YAML mapping") )
Parse errors.
Functions ¶
This section is empty.
Types ¶
type ConflictPolicy ¶
type ConflictPolicy string
ConflictPolicy defines how to handle merge conflicts.
const ( // ConflictError returns an error when a key exists with different content. ConflictError ConflictPolicy = "error" // ConflictSkip silently skips conflicting keys. ConflictSkip ConflictPolicy = "skip" )
type Editor ¶
type Editor struct{}
Editor provides structural merge of OpenAPI YAML fragments.
func (*Editor) Merge ¶
func (e *Editor) Merge(spec, fragment []byte, opts MergeOptions) ([]byte, MergeResult, error)
Merge merges an OpenAPI YAML fragment into a target spec. The fragment should contain top-level `paths` and/or `components` sections. Returns the merged YAML, a result summary, and any error.
type MergeOptions ¶
type MergeOptions struct {
ValidateResult bool // run kin-openapi validation after merge
ConflictPolicy ConflictPolicy // skip | error (default: error)
}
MergeOptions controls merge behavior.
type MergeResult ¶
type MergeResult struct {
Changed bool
AddedPaths []string
AddedSchemas []string
SkippedPaths []string
SkippedSchemas []string
Conflicts []string
}
MergeResult describes what the merge operation did.
type Spec ¶
type Spec struct {
File *ast.File
Root *ast.MappingNode
Indent int // detected indentation (2 or 4 spaces)
}
Spec wraps a parsed OpenAPI YAML AST with indexed access to top-level sections.
func (*Spec) HasComponents ¶
HasComponents returns true if the spec has a `components` section.
func (*Spec) HasSchemas ¶
HasSchemas returns true if the spec has a `components.schemas` section (even if empty).
func (*Spec) Paths ¶
func (s *Spec) Paths() *ast.MappingNode
Paths returns the `paths` mapping node, or nil if absent.
func (*Spec) Schemas ¶
func (s *Spec) Schemas() *ast.MappingNode
Schemas returns the `components.schemas` mapping node, or nil if absent.