diff

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 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 {
	PathDiff   *PathsDiff   `json:"paths,omitempty"`
	SchemaDiff *SchemasDiff `json:"schemas,omitempty"`
}

Diff describes the changes between two OAS specs

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 MethodDiff

type MethodDiff struct {
	ParamDiff    *ParametersDiff `json:"parameters,omitempty"`
	ResponseDiff *ResponsesDiff  `json:"responses,omitempty"`
}

MethodDiff is the diff between two methods

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 value 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 (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 in operations (methods) of two paths

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"`
	StyleDiff           *ValueDiff   `json:"style,omitempty"`
	ExplodeDiff         *ValueDiff   `json:"explode,omitempty"`
	AllowEmptyValueDiff *ValueDiff   `json:"allow_empty_value,omitempty"`
	AllowReservedDiff   *ValueDiff   `json:"allow_reserved,omitempty"`
	DeprecatedDiff      *ValueDiff   `json:"deprecated,omitempty"`
	RequiredDiff        *ValueDiff   `json:"required,omitempty"`
	SchemaDiff          *SchemaDiff  `json:"schema,omitempty"`
	ContentDiff         *ContentDiff `json:"content,omitempty"`
}

ParameterDiff is a diff between two 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 of parameters between two two operations

type PathDiff

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

PathDiff is the diff between two paths

type PathList added in v0.1.5

type PathList []string

PathList is a list of paths

type PathSummary added in v0.0.9

type PathSummary struct {
	Added    int `json:"added,omitempty"`
	Deleted  int `json:"deleted,omitempty"`
	Modified int `json:"modified,omitempty"`
}

PathSummary summarizes the path changes between two specs

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 {
}

ResponseDiff is a diff between two 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 Result added in v0.0.9

type Result struct {
	Diff    *Diff    `json:"diff,omitempty"`
	Summary *Summary `json:"summary,omitempty"`
}

Result includes a diff of changes between two OAS specs and a summary of these changes

func Run added in v0.0.9

func Run(s1, s2 *openapi3.Swagger, prefix string, filter string) Result

Run calculates the diff between two OAS specs including a summary. 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 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"`
	AnyOfDiff                       bool       `json:"anyOf,omitempty"`
	AllOfDiff                       bool       `json:"allOf,omitempty"`
	NotDiff                         bool       `json:"not,omitempty"`
	TypeDiff                        *ValueDiff `json:"type,omitempty"`
	TitleDiff                       *ValueDiff `json:"title,omitempty"`
	FormatDiff                      *ValueDiff `json:"format,omitempty"`
	DescriptionDiff                 *ValueDiff `json:"description,omitempty"`
	EnumDiff                        *EnumDiff  `json:"enum,omitempty"`
	AdditionalPropertiesAllowedDiff *ValueDiff `json:"additionalPropertiesAllowed,omitempty"`
	UniqueItemsDiff                 *ValueDiff `json:"uniqueItems,omitempty"`
	ExclusiveMinDiff                *ValueDiff `json:"exclusiveMin,omitempty"`
	ExclusiveMaxDiff                *ValueDiff `json:"exclusiveMax,omitempty"`
	NullableDiff                    *ValueDiff `json:"nullable,omitempty"`
	ReadOnlyDiff                    *ValueDiff `json:"readOnlyDiff,omitempty"`
	WriteOnlyDiff                   *ValueDiff `json:"writeOnlyDiff,omitempty"`
	AllowEmptyValueDiff             *ValueDiff `json:"allowEmptyValue,omitempty"`
	DeprecatedDiff                  *ValueDiff `json:"deprecated,omitempty"`
	MinDiff                         *ValueDiff `json:"min,omitempty"`
	MaxDiff                         *ValueDiff `json:"max,omitempty"`
	MultipleOf                      *ValueDiff `json:"multipleOf,omitempty"`
	MinLength                       *ValueDiff `json:"minLength,omitempty"`
	MaxLength                       *ValueDiff `json:"maxLength,omitempty"`
	Pattern                         *ValueDiff `json:"pattern,omitempty"`
	MinItems                        *ValueDiff `json:"minItems,omitempty"`
	MaxItems                        *ValueDiff `json:"maxItems,omitempty"`
	Items                           bool       `json:"items,omitempty"`
	PropertiesDiff                  bool       `json:"properties,omitempty"`
	MinProps                        *ValueDiff `json:"minProps,omitempty"`
	MaxProps                        *ValueDiff `json:"maxProps,omitempty"`
	AdditionalProperties            bool       `json:"additionalProperties,omitempty"`
}

SchemaDiff is a diff between two schemas

type SchemaList added in v0.1.5

type SchemaList []string

SchemaList is a list of schema names

type SchemaSummary added in v0.0.9

type SchemaSummary struct {
	Added    int `json:"added,omitempty"`
	Deleted  int `json:"deleted,omitempty"`
	Modified int `json:"modified,omitempty"`
}

SchemaSummary summarizes the schema changes between two specs

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 Summary added in v0.0.9

type Summary struct {
	Diff          bool           `json:"diff"`
	PathSummary   *PathSummary   `json:"paths,omitempty"`
	SchemaSummary *SchemaSummary `json:"schemas,omitempty"`
}

Summary summarizes the changes between two specs

type ValueDiff

type ValueDiff struct {
	OldValue interface{} `json:"oldValue"`
	NewValue interface{} `json:"newValue"`
}

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