differ

package
v0.0.0-...-4ebe608 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package differ knowns how to Diff and Patch a pair of jsonschema.Schema s.

Diff

Differences are qualified to detect breaking changes or backward-compatible changes.

Patch

A jsonschema.Overlay is produced that when applied to the first jsonschema.Schema, yields the second one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteReport

func WriteReport(w io.Writer, r Result, opts ...ReportOption) error

WriteReport knows how to render a diff Result as a human readable report.

Types

type CategoryMode

type CategoryMode uint8

CategoryMode qualifies the nature of a schema change, such as version of jsonchema, metadata only, validations only etc.

Several categories may apply to a single change.

const (
	CategoryNone    CategoryMode = 1 << iota
	CategoryVersion              // JSON schema version
	CategoryMetadata
	CategoryLocation // change in $ref
	CategoryValidation
	CategoryDataType
)

type Change

type Change struct {
	// contains filtered or unexported fields
}

type ChangesOption

type ChangesOption func(*changesOptions)

type Differ

type Differ struct {
	// contains filtered or unexported fields
}

Differ knows how to compare two versions of a json schema.

func New

func New(opts ...Option) *Differ

func (*Differ) Diff

func (d *Differ) Diff(old, new jsonschema.Schema) Result

Diff computes the differences between new and old jsonschema.Schema as a diff Result.

func (*Differ) Patch

func (d *Differ) Patch(old, new jsonschema.Schema) jsonschema.Overlay

Diff computes a jsonschema.Overlay patch that when applied to old, produces the new schema.

type Option

type Option func(*options)

func WithIgnoreCosmeticChanges

func WithIgnoreCosmeticChanges(enabled bool) Option

type ReportOption

type ReportOption func(*reportOptions)

func WithThreshold

func WithThreshold(minSeverity Severity) ReportOption

type ReportOutputMode

type ReportOutputMode uint8
const (
	ReportOutputTable ReportOutputMode = 1 << iota
	ReportOutputMarkdown
	ReportOutputHTML
)

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result of the differences analysis between two schemas.

func (Result) Changes

func (r Result) Changes(opts ...ChangesOption) iter.Seq[Change]

type Severity

type Severity uint8

Severity qualifies the impact of a change, from cosmetic to breaking change.

const (
	SeverityNone Severity = iota
	SeverityCosmetic
	SeverityDocOnly
	SeverityPatch
	SeverityMinor // compatible
	SeverityBreaking
)

func (Severity) Less

func (s Severity) Less(other Severity) bool

type Type

type Type uint

Type of change, e.g. update, addition or deletion.

const (
	TypeNoChange Type = iota
	Deleted
	Added
	Updated
)

type ValidationCategory

type ValidationCategory uint8

ValidationCategory indicates more precisely the type of validation to which a change with ValidationCategory is eligible.

const (
	NumberValidation ValidationCategory = iota
	StringValidation
	ObjectValidation
	ArrayValidation
	EnumValidation
)

Jump to

Keyboard shortcuts

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