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.
var ReservedKeys = []string{"operation", "operations", "schemas", "info", "servers", "security"}
ReservedKeys are the vars namespaces ExtractOperation produces. On collision with template- or config-declared vars these win (they are reserved for OpenAPI input); an explicit --meta flag still overrides them, as --meta is applied later at the highest precedence by the engine.
Functions ¶
func ExtractOperation ¶ added in v0.37.0
ExtractOperation parses an OpenAPI 3.x spec and extracts a single operation (selected by operationId or "METHOD /path") into a map[string]any suitable for the template `vars` namespace. See claudedocs/openapi-input-plan.md.
func ExtractOperations ¶ added in v0.38.0
ExtractOperations parses an OpenAPI 3.x spec and extracts many operations into a map[string]any for the template `vars` namespace. An empty tag selects every operation; otherwise only operations carrying that OpenAPI tag. Operations are ordered by path then method for deterministic output, and each entry carries its own effective security (op-level, else spec-level) — there is no top-level `security` key in multi-op mode, since it differs per operation. vars.schemas is the deduped union of components referenced by all selected operations. See #327.
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.