diff

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Kind     ChangeKind
	Location string
	From     string
	To       string
	Severity Severity
	Note     string
	Target   Target
}

type ChangeKind

type ChangeKind string
const (
	OperationAdded   ChangeKind = "operation_added"
	OperationRemoved ChangeKind = "operation_removed"

	ParameterAdded           ChangeKind = "parameter_added"
	ParameterRemoved         ChangeKind = "parameter_removed"
	ParameterTypeChanged     ChangeKind = "parameter_type_changed"
	ParameterRequiredChanged ChangeKind = "parameter_required_changed"

	ResponseAdded   ChangeKind = "response_added" // status code
	ResponseRemoved ChangeKind = "response_removed"

	SchemaAdded         ChangeKind = "schema_added"
	SchemaRemoved       ChangeKind = "schema_removed"
	PropertyAdded       ChangeKind = "property_added"
	PropertyRemoved     ChangeKind = "property_removed"
	PropertyTypeChanged ChangeKind = "property_type_changed"
	PropertyRenamed     ChangeKind = "property_renamed"
	RequiredAdded       ChangeKind = "required_added"
	RequiredRemoved     ChangeKind = "required_removed"
)

type Direction

type Direction int

Direction is where a schema sits on the contract: client->server or server->client.

const (
	Request Direction = iota
	Response
)

func (Direction) String

func (d Direction) String() string

type Report

type Report struct{ Changes []Change }

func Diff

func Diff(a, b *ir.Document) *Report

Diff compares two CANONICAL documents (a=published, b=code). Detection is symmetric; direction only affects how severe a found change is.

func (*Report) Breaking

func (r *Report) Breaking() int

func (*Report) JSON

func (r *Report) JSON() (string, error)

JSON renders the report as machine-readable JSON for other tools/CI.

func (*Report) Markdown

func (r *Report) Markdown() string

Markdown renders the report as a PR-friendly markdown summary: a one-line headline, then a table grouped severity-first (breaking on top) and sorted deterministically so the same drift always produces the same document.

func (*Report) Text

func (r *Report) Text() string

Text renders the plain, terminal-style report (what the CLI printed inline).

type Severity

type Severity int
const (
	Info Severity = iota
	Breaking
)

func (Severity) String

func (s Severity) String() string

type Target

type Target struct {
	// schema-property changes
	Schema    string
	Direction Direction
	Property  string
	// operation / parameter / response changes
	Method     string
	Path       string
	ParamName  string
	ParamIn    string
	StatusCode string
}

Target is the machine-addressable location of a change, so downstream (patch) never parses the human-readable Location string. Fields are populated per change kind; unused ones stay zero.

Jump to

Keyboard shortcuts

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