diff

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package diff provides a diff function for OpenAPI Spec 3. Work to enhance the diff with additional aspects of OAS is in-progress.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentDiff

type ContentDiff struct {
	MediaTypeAdded   bool `json:"mediaTypeAdded,omitempty"`
	MediaTypeDeleted bool `json:"mediaTypeDeleted,omitempty"`
	MediaTypeDiff    bool `json:"mediaTypeDiff,omitempty"`

	SchemaDiff *SchemaDiff `json:"schemaDiff,omitempty"`
}

ContentDiff is the diff between two OAS contents

type Diff

type Diff struct {
	SpecDiff *SpecDiff `json:"spec,omitempty"`
	Summary  *Summary  `json:"summary,omitempty"`
}

Diff describes changes between two OAS specs including a summary of these changes

func Get added in v0.1.9

func Get(s1, s2 *openapi3.Swagger, prefix string, filter string) Diff

Get calculates the diff between two OAS specs. Prefix is an optional path prefix that exists in s1 paths but not in s2. If filter isn't empty, the diff will only include paths that match this regex.

type EnumDiff added in v0.1.3

type EnumDiff struct {
	Added   EnumValues `json:"added,omitempty"`
	Deleted EnumValues `json:"deleted,omitempty"`
}

EnumDiff is the diff between two OAS enums

type EnumValues added in v0.1.5

type EnumValues []interface{}

EnumValues is a list of enum values

type HeaderDiff added in v0.1.10

type HeaderDiff struct {

	// ExtensionProps
	DescriptionDiff *ValueDiff   `json:"description,omitempty"` // diff of 'description' property
	DeprecatedDiff  *ValueDiff   `json:"deprecated,omitempty"`  // diff of 'deprecated' property
	RequiredDiff    *ValueDiff   `json:"required,omitempty"`    // diff of 'required' property
	SchemaDiff      *SchemaDiff  `json:"schema,omitempty"`      // diff of 'schema' property
	ContentDiff     *ContentDiff `json:"content,omitempty"`     // diff of 'content' property
}

HeaderDiff is a diff between two OAS headers

type HeaderList added in v0.1.10

type HeaderList []string

HeaderList is a list of header values

type HeadersDiff added in v0.1.10

type HeadersDiff struct {
	Added    HeaderList      `json:"added,omitempty"`
	Deleted  HeaderList      `json:"deleted,omitempty"`
	Modified ModifiedHeaders `json:"modified,omitempty"`
}

HeadersDiff is a diff between two sets of headers

type MethodDiff

type MethodDiff struct {

	// ExtensionProps
	// Tags
	SummaryDiff     *ValueDiff      `json:"summary,omitempty"`     // diff of 'summary' property
	DescriptionDiff *ValueDiff      `json:"description,omitempty"` // diff of 'description' property
	OperationIDDiff *ValueDiff      `json:"operationID,omitempty"` // diff of 'operationID' property
	ParamDiff       *ParametersDiff `json:"parameters,omitempty"`  // diff of 'parameters' property
	// RequestBody
	ResponseDiff *ResponsesDiff `json:"responses,omitempty"` // diff of 'responses' property
	// Callbacks
	DeprecatedDiff *ValueDiff `json:"deprecated,omitempty"` // diff of 'deprecated' property

}

MethodDiff is the diff between two OAS operations (methods)

type ModifiedHeaders added in v0.1.10

type ModifiedHeaders map[string]HeaderDiff

ModifiedHeaders is map of header values to their respective diffs

type ModifiedOperations

type ModifiedOperations map[string]*MethodDiff

ModifiedOperations is a map of HTTP methods to their respective diffs

type ModifiedPaths added in v0.1.5

type ModifiedPaths map[string]*PathDiff

ModifiedPaths is a map of paths to their respective diffs

type ModifiedResponses added in v0.1.5

type ModifiedResponses map[string]ResponseDiff

ModifiedResponses is map of response values to their respective diffs

type ModifiedSchemas

type ModifiedSchemas map[string]*SchemaDiff

ModifiedSchemas is map of schema names to their respective diffs

type OperationList added in v0.0.9

type OperationList []string

OperationList is a list of operations (HTTP methods)

type Operations added in v0.0.9

type Operations struct {
	Added    OperationList      `json:"added,omitempty"`
	Deleted  OperationList      `json:"deleted,omitempty"`
	Modified ModifiedOperations `json:"modified,omitempty"`
}

Operations is the diff between two sets of operations (methods)

type ParamDiffByLocation added in v0.1.4

type ParamDiffByLocation map[string]ParamDiffs

ParamDiffByLocation maps param location (path, query, header or cookie) to param diffs in this location

type ParamDiffs

type ParamDiffs map[string]ParameterDiff

ParamDiffs is map of parameter names to their respective diffs

type ParamNames

type ParamNames map[string]struct{}

ParamNames is a set of parameter names

type ParamNamesByLocation added in v0.1.4

type ParamNamesByLocation map[string]ParamNames

ParamNamesByLocation maps param location (path, query, header or cookie) to the params in this location

type ParameterDiff added in v0.1.5

type ParameterDiff struct {
	DescriptionDiff     *ValueDiff   `json:"description,omitempty"`     // diff of 'description' property
	StyleDiff           *ValueDiff   `json:"style,omitempty"`           // diff of 'style' property
	ExplodeDiff         *ValueDiff   `json:"explode,omitempty"`         // diff of 'explode' property
	AllowEmptyValueDiff *ValueDiff   `json:"allowEmptyValue,omitempty"` // diff of 'allowEmptyValue' property
	AllowReservedDiff   *ValueDiff   `json:"allowReserved,omitempty"`   // diff of 'allowReserved' property
	DeprecatedDiff      *ValueDiff   `json:"deprecated,omitempty"`      // diff of 'deprecated' property
	RequiredDiff        *ValueDiff   `json:"required,omitempty"`        // diff of 'required' property
	SchemaDiff          *SchemaDiff  `json:"schema,omitempty"`          // diff of 'schema' property
	ContentDiff         *ContentDiff `json:"content,omitempty"`         // diff of 'content' property
}

ParameterDiff is a diff between two OAS parameters

type ParametersDiff added in v0.1.5

type ParametersDiff struct {
	Added    ParamNamesByLocation `json:"added,omitempty"`
	Deleted  ParamNamesByLocation `json:"deleted,omitempty"`
	Modified ParamDiffByLocation  `json:"modified,omitempty"`
}

ParametersDiff is the diff between two sets of parameters

type PathDiff

type PathDiff struct {
	Operations `json:"operations,omitempty"`
}

PathDiff is the diff between two OAS paths

type PathList added in v0.1.5

type PathList []string

PathList is a list of paths

type PathsDiff added in v0.1.5

type PathsDiff struct {
	Added    PathList      `json:"added,omitempty"`
	Deleted  PathList      `json:"deleted,omitempty"`
	Modified ModifiedPaths `json:"modified,omitempty"`
}

PathsDiff is a diff between two sets of paths

type ResponseDiff added in v0.1.5

type ResponseDiff struct {
	// ExtensionProps
	DescriptionDiff *ValueDiff   `json:"description,omitempty"` // diff of 'description' property
	HeadersDiff     *HeadersDiff `json:"headers,omitempty"`     // diff of 'headers' property
	ContentDiff     *ContentDiff `json:"content,omitempty"`     // diff of 'content' property

}

ResponseDiff is a diff between two OAS responses

type ResponseList added in v0.1.5

type ResponseList []string

ResponseList is a list of response values

type ResponsesDiff added in v0.1.5

type ResponsesDiff struct {
	Added    ResponseList      `json:"added,omitempty"`
	Deleted  ResponseList      `json:"deleted,omitempty"`
	Modified ModifiedResponses `json:"modified,omitempty"`
}

ResponsesDiff is a diff between two sets of responses

type SchemaDiff

type SchemaDiff struct {
	SchemaAdded                     bool         `json:"schemaAdded,omitempty"`
	SchemaDeleted                   bool         `json:"schemaDeleted,omitempty"`
	ValueAdded                      bool         `json:"valueAdded,omitempty"`
	ValueDeleted                    bool         `json:"valueDeleted,omitempty"`
	OneOfDiff                       bool         `json:"oneOf,omitempty"`                       // whether 'oneOf' property was modified or not
	AnyOfDiff                       bool         `json:"anyOf,omitempty"`                       // whether 'anyOf' property was modified or not
	AllOfDiff                       bool         `json:"allOf,omitempty"`                       // whether 'allOf' property was modified or not
	NotDiff                         bool         `json:"not,omitempty"`                         // whether 'not' property was modified or not
	TypeDiff                        *ValueDiff   `json:"type,omitempty"`                        // diff of 'type' property
	TitleDiff                       *ValueDiff   `json:"title,omitempty"`                       // diff of 'title' property
	FormatDiff                      *ValueDiff   `json:"format,omitempty"`                      // diff of 'format' property
	DescriptionDiff                 *ValueDiff   `json:"description,omitempty"`                 // diff of 'description' property
	EnumDiff                        *EnumDiff    `json:"enum,omitempty"`                        // diff of 'enum' property
	AdditionalPropertiesAllowedDiff *ValueDiff   `json:"additionalPropertiesAllowed,omitempty"` // diff of 'additionalPropertiesAllowed' property
	UniqueItemsDiff                 *ValueDiff   `json:"uniqueItems,omitempty"`                 // diff of 'uniqueItems' property
	ExclusiveMinDiff                *ValueDiff   `json:"exclusiveMin,omitempty"`                // diff of 'exclusiveMin' property
	ExclusiveMaxDiff                *ValueDiff   `json:"exclusiveMax,omitempty"`                // diff of 'exclusiveMax' property
	NullableDiff                    *ValueDiff   `json:"nullable,omitempty"`                    // diff of 'nullable' property
	ReadOnlyDiff                    *ValueDiff   `json:"readOnlyDiff,omitempty"`                // diff of 'readOnlyDiff' property
	WriteOnlyDiff                   *ValueDiff   `json:"writeOnlyDiff,omitempty"`               // diff of 'writeOnlyDiff' property
	AllowEmptyValueDiff             *ValueDiff   `json:"allowEmptyValue,omitempty"`             // diff of 'allowEmptyValue' property
	DeprecatedDiff                  *ValueDiff   `json:"deprecated,omitempty"`                  // diff of 'deprecated' property
	MinDiff                         *ValueDiff   `json:"min,omitempty"`                         // diff of 'min' property
	MaxDiff                         *ValueDiff   `json:"max,omitempty"`                         // diff of 'max' property
	MultipleOf                      *ValueDiff   `json:"multipleOf,omitempty"`                  // diff of 'multipleOf' property
	MinLength                       *ValueDiff   `json:"minLength,omitempty"`                   // diff of 'minLength' property
	MaxLength                       *ValueDiff   `json:"maxLength,omitempty"`                   // diff of 'maxLength' property
	Pattern                         *ValueDiff   `json:"pattern,omitempty"`                     // diff of 'pattern' property
	MinItems                        *ValueDiff   `json:"minItems,omitempty"`                    // diff of 'minItems' property
	MaxItems                        *ValueDiff   `json:"maxItems,omitempty"`                    // diff of 'maxItems' property
	Items                           bool         `json:"items,omitempty"`                       // whether 'items' property was modified or not
	PropertiesDiff                  *SchemasDiff `json:"properties,omitempty"`                  // diff of 'properties' property
	MinProps                        *ValueDiff   `json:"minProps,omitempty"`                    // diff of 'minProps' property
	MaxProps                        *ValueDiff   `json:"maxProps,omitempty"`                    // diff of 'maxProps' property
	AdditionalProperties            bool         `json:"additionalProperties,omitempty"`        // whether 'additionalProperties' property was modified or not
}

SchemaDiff is a diff between two OAS schemas

type SchemaList added in v0.1.5

type SchemaList []string

SchemaList is a list of schema names

type SchemasDiff added in v0.1.5

type SchemasDiff struct {
	Added    SchemaList      `json:"added,omitempty"`
	Deleted  SchemaList      `json:"deleted,omitempty"`
	Modified ModifiedSchemas `json:"modified,omitempty"`
}

SchemasDiff is a diff between two sets of schemas

type SpecDiff added in v0.1.9

type SpecDiff struct {
	PathsDiff      *PathsDiff      `json:"paths,omitempty"`      // deep diff of paths including their schemas, parameters, responses etc.
	SchemasDiff    *SchemasDiff    `json:"schemas,omitempty"`    // diff of top-level schemas (under components)
	ParametersDiff *ParametersDiff `json:"parameters,omitempty"` // diff of top-level parameters (under components)
	HeadersDiff    *HeadersDiff    `json:"headers,omitempty"`    // diff of top-level headers (under components)
	ResponsesDiff  *ResponsesDiff  `json:"responses,omitempty"`  // diff of top-level responses (under components)
}

SpecDiff describes the changes between two OAS specs

type Summary added in v0.0.9

type Summary struct {
	Diff             bool            `json:"diff"`
	PathSummary      *SummaryDetails `json:"paths,omitempty"`
	SchemaSummary    *SummaryDetails `json:"schemas,omitempty"`
	ParameterSummary *SummaryDetails `json:"parameters,omitempty"`
	HeaderSummary    *SummaryDetails `json:"headers,omitempty"`
	ResponsesSummary *SummaryDetails `json:"responses,omitempty"`
}

Summary summarizes the changes between two OAS specs

type SummaryDetails added in v0.1.8

type SummaryDetails struct {
	Added    int `json:"added,omitempty"`    // how many items were added
	Deleted  int `json:"deleted,omitempty"`  // how many items were deleted
	Modified int `json:"modified,omitempty"` // how many items were modified
}

SummaryDetails summarizes the changes between equivalent parts of the two OAS spec: paths, schemas, parameters, headers, responses etc.

type ValueDiff

type ValueDiff struct {
	From interface{} `json:"from"`
	To   interface{} `json:"to"`
}

ValueDiff describes the diff between two values

Jump to

Keyboard shortcuts

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