Help us shape the future of Go! Take the 2026 Go Developer Survey

patch

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op string
const (
	OpAdd     Op = "add"
	OpRemove  Op = "remove"
	OpReplace Op = "replace"
	// OpRenameRef rewrites every `$ref: RefFrom` anywhere in the document to
	// RefTo. Unlike the other ops, it isn't addressed by Path — a $ref to a
	// renamed schema can appear anywhere (other schemas' properties, array
	// items, any operation's request/response), so the applier walks the
	// whole tree instead of resolving one JSON Pointer.
	OpRenameRef Op = "rename_ref"
)

type Patch

type Patch struct {
	Op          Op
	Path        string            // JSON Pointer (RFC 6901) into the published document
	Value       *yaml.Node        // fragment to add/replace, copied from the code doc; nil for remove
	Match       map[string]string // identify an array element (parameters: name+in)
	RefFrom     string            // OpRenameRef only: the $ref value to find
	RefTo       string            // OpRenameRef only: its replacement
	CreatePath  bool              // for add: create missing map ancestors (new operations)
	Description string            // prose slot, filled by the later LLM stage
	Reason      string            // provenance: which drift this resolves (for review)
	Severity    diff.Severity
}

Patch is a single, reviewable INTENT to change the published document. It is data, not an edit: a later applier executes it only after human approval. Value comes from the code side; Description is a slot the LLM stage fills later (empty here, since this generator is fully deterministic).

func FromReport

func FromReport(report *diff.Report, code *ir.Document) ([]Patch, error)

FromReport turns detected drift into a deterministic list of patch intents. The code document supplies the authoritative values (code-first authority).

A shared schema drifts once per direction (request/response) for severity, but a document edit is direction-agnostic, so identical patches are deduped here.

Jump to

Keyboard shortcuts

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