diff

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 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"`
}

type Diff

type Diff struct {
	PathDiff   *PathDiff             `json:"endpoints,omitempty"`
	SchemaDiff *SchemaCollectionDiff `json:"schemas,omitempty"`
}

type EndpointDiff

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

type EnumDiff added in v0.1.3

type EnumDiff struct {
	Added   []interface{} `json:"added,omitempty"`
	Deleted []interface{} `json:"deleted,omitempty"`
}

type MethodDiff

type MethodDiff struct {
	Params `json:"parameters,omitempty"`
}

type ModifiedEndpoints

type ModifiedEndpoints map[string]*EndpointDiff // key is endpoint (path)

type ModifiedOperations

type ModifiedOperations map[string]*MethodDiff // key is HTTP method

type ModifiedSchemas

type ModifiedSchemas map[string]*SchemaDiff

type OperationList added in v0.0.9

type OperationList []string

type Operations added in v0.0.9

type Operations struct {
	AddedOperations    OperationList      `json:"added,omitempty"`
	DeletedOperations  OperationList      `json:"deleted,omitempty"`
	ModifiedOperations ModifiedOperations `json:"modified,omitempty"`
}

type ParamDiff

type ParamDiff 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"`
}

type ParamDiffs

type ParamDiffs map[string]ParamDiff // key is param name

type ParamNames

type ParamNames map[string]struct{} // key is param name

type Params added in v0.0.9

type Params struct {
	AddedParams    map[string]ParamNames `json:"added,omitempty"`    // key is param location (path, query, header or cookie)
	DeletedParams  map[string]ParamNames `json:"deleted,omitempty"`  // key is param location
	ModifiedParams map[string]ParamDiffs `json:"modified,omitempty"` // key is param location
}

type PathDiff

type PathDiff struct {
	AddedEndpoints    []string          `json:"added,omitempty"`
	DeletedEndpoints  []string          `json:"deleted,omitempty"`
	ModifiedEndpoints ModifiedEndpoints `json:"modified,omitempty"`
}

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"`
}

type Result added in v0.0.9

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

func Run added in v0.0.9

func Run(s1 *openapi3.Swagger, 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 endpoints but not in s2. If filter isn't empty, the diff will only include endpoints that match this regex.

type SchemaCollectionDiff

type SchemaCollectionDiff struct {
	AddedSchemas    []string        `json:"added,omitempty"`
	DeletedSchemas  []string        `json:"deleted,omitempty"`
	ModifiedSchemas ModifiedSchemas `json:"modified,omitempty"`
}

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"`
}

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"`
}

type Summary added in v0.0.9

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

type ValueDiff

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

Jump to

Keyboard shortcuts

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