Documentation
¶
Overview ¶
Package diff compares OpenAPI documents using libopenapi's semantic diff engine.
Index ¶
- func FormatJSON(r *Result, w io.Writer) error
- func FormatMarkdown(r *Result, w io.Writer, opts FormatOpts) error
- func FormatSARIF(r *Result, w io.Writer, opts FormatOpts) error
- func FormatText(r *Result, w io.Writer, opts FormatOpts) error
- func LoadBreakingRules(path string) (*model.BreakingRulesConfig, error)
- func ParseGitSpec(arg string) (ref, path string, ok bool)
- func ReadAtRef(repoRoot, ref, filePath string) ([]byte, error)
- func ResolveArg(arg, repoRoot string) ([]byte, error)
- type CompareOpts
- type FormatOpts
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatJSON ¶
FormatJSON writes a JSON summary compatible with machine-readable reports.
func FormatMarkdown ¶
func FormatMarkdown(r *Result, w io.Writer, opts FormatOpts) error
FormatMarkdown writes a markdown table of changes.
func FormatSARIF ¶
func FormatSARIF(r *Result, w io.Writer, opts FormatOpts) error
FormatSARIF writes SARIF 2.1.0 with one result per breaking change (and optionally all changes).
func FormatText ¶
func FormatText(r *Result, w io.Writer, opts FormatOpts) error
FormatText writes a human-readable summary of changes.
func LoadBreakingRules ¶
func LoadBreakingRules(path string) (*model.BreakingRulesConfig, error)
LoadBreakingRules loads openapi-changes-style breaking rules from a YAML file.
func ParseGitSpec ¶
ParseGitSpec parses "REF:path/to/file.yaml" into ref and path. On Windows, paths like "C:\foo" are not treated as git specs (single-letter drive + colon).
func ReadAtRef ¶
ReadAtRef reads a file at ref:path from a git repository using git show. repoRoot is the working tree root; ref is a branch, tag, or commit; filePath is relative to repo root.
func ResolveArg ¶
ResolveArg loads bytes for a CLI argument: either a filesystem path or REF:path for git.
Types ¶
type CompareOpts ¶
type CompareOpts struct {
// BreakingRulesPath, if set, loads custom breaking rules from YAML (openapi-changes format).
BreakingRulesPath string
}
CompareOpts configures Compare.
type Result ¶
type Result struct {
Changes *model.DocumentChanges
// CompareErrs collects non-fatal errors from building models (libopenapi may still return Changes).
CompareErrs error
}
Result holds the outcome of comparing two OpenAPI documents.
func Compare ¶
func Compare(original, updated []byte, opts CompareOpts) (*Result, error)
Compare parses original and updated spec bytes and runs libopenapi.CompareDocuments.
func (*Result) TotalBreakingChanges ¶
TotalBreakingChanges returns how many changes are classified as breaking.
func (*Result) TotalChanges ¶
TotalChanges returns the total number of semantic changes.