diff

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package diff compares OpenAPI documents using libopenapi's semantic diff engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatJSON

func FormatJSON(r *Result, w io.Writer) error

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

func ParseGitSpec(arg string) (ref, path string, ok bool)

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

func ReadAtRef(repoRoot, ref, filePath string) ([]byte, error)

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

func ResolveArg(arg, repoRoot string) ([]byte, error)

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 FormatOpts

type FormatOpts struct {
	BreakingOnly bool
}

FormatOpts controls text output.

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

func (r *Result) TotalBreakingChanges() int

TotalBreakingChanges returns how many changes are classified as breaking.

func (*Result) TotalChanges

func (r *Result) TotalChanges() int

TotalChanges returns the total number of semantic changes.

Jump to

Keyboard shortcuts

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