go-swagger: github.com/go-swagger/go-swagger/cmd/swagger/commands/diff Index | Files

package diff

import "github.com/go-swagger/go-swagger/cmd/swagger/commands/diff"

Index

Package Files

array_diff.go compatibility.go difference_location.go difftypes.go node.go reporting.go spec_analyser.go spec_difference.go type_adapters.go

Constants

const StringType = "string"

Variables

var ArrayType = "array"

ArrayType const for array

func JSONMarshal Uses

func JSONMarshal(t interface{}) ([]byte, error)

JSONMarshal allows the item to be correctly rendered to json

type Compatibility Uses

type Compatibility int

Compatibility - whether this is a breaking or non-breaking change

const (
    // Breaking this change could break existing clients
    Breaking Compatibility = iota
    // NonBreaking This is a backwards-compatible API change
    NonBreaking
)

func (*Compatibility) MarshalJSON Uses

func (s *Compatibility) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (Compatibility) String Uses

func (s Compatibility) String() string

func (*Compatibility) UnmarshalJSON Uses

func (s *Compatibility) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type CompatibilityPolicy Uses

type CompatibilityPolicy struct {
    ForResponse map[SpecChangeCode]Compatibility
    ForRequest  map[SpecChangeCode]Compatibility
    ForChange   map[SpecChangeCode]Compatibility
}

CompatibilityPolicy decides which changes are breaking and which are not

type DataDirection Uses

type DataDirection int

DataDirection indicates the direction of change Request vs Response

const (
    // Request Used for messages/param diffs in a request
    Request DataDirection = iota
    // Response Used for messages/param diffs in a response
    Response
)

type DifferenceLocation Uses

type DifferenceLocation struct {
    URL      string `json:"url"`
    Method   string `json:"method,omitempty"`
    Response int    `json:"response,omitempty"`
    Node     *Node  `json:"node,omitempty"`
}

DifferenceLocation indicates where the difference occurs

func (DifferenceLocation) AddNode Uses

func (dl DifferenceLocation) AddNode(node *Node) DifferenceLocation

AddNode returns a copy of this location with the leaf node added

type FromArrayStruct Uses

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

FromArrayStruct utility struct to encompass diffing of string arrays

func FromStringArray Uses

func FromStringArray(from []string) FromArrayStruct

FromStringArray starts a fluent diff expression

func (FromArrayStruct) DiffsTo Uses

func (f FromArrayStruct) DiffsTo(toArray []string) (added, deleted, common []string)

DiffsTo completes a fluent dff expression

type FromMapStruct Uses

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

FromMapStruct utility struct to encompass diffing of string arrays

func FromStringMap Uses

func FromStringMap(srcMap map[string]interface{}) FromMapStruct

FromStringMap starts a comparison by declaring a source map

func (FromMapStruct) DiffsTo Uses

func (f FromMapStruct) DiffsTo(destMap map[string]interface{}) (added, deleted, common map[string]interface{})

DiffsTo - generates diffs for a comparison

type Node Uses

type Node struct {
    Field     string `json:"name,omitempty"`
    TypeName  string `json:"type,omitempty"`
    IsArray   bool   `json:"is_array,omitempty"`
    ChildNode *Node  `json:"child,omitempty"`
}

Node is the position od a diff in a spec

func (*Node) AddLeafNode Uses

func (n *Node) AddLeafNode(toAdd *Node) *Node

AddLeafNode Adds (recursive) a Child to the first non-nil child found

func (Node) Copy Uses

func (n Node) Copy() *Node

Copy deep copy of this node and children

func (*Node) String Uses

func (n *Node) String() string

String std string render

type OperationMap Uses

type OperationMap map[string]*spec.Operation

OperationMap saves indexing operations in PathItems individually

type Pair Uses

type Pair struct {
    First  interface{}
    Second interface{}
}

Pair stores a pair of items which share a key in two maps

type PathItemOp Uses

type PathItemOp struct {
    ParentPathItem *spec.PathItem  `json:"pathitem"`
    Operation      *spec.Operation `json:"operation"`
}

PathItemOp - combines path and operation into a single keyed entity

type SpecAnalyser Uses

type SpecAnalyser struct {
    Diffs SpecDifferences

    Definitions1               spec.Definitions
    Definitions2               spec.Definitions
    AlreadyComparedDefinitions map[string]bool
    // contains filtered or unexported fields
}

SpecAnalyser contains all the differences for a Spec

func NewSpecAnalyser Uses

func NewSpecAnalyser() *SpecAnalyser

NewSpecAnalyser returns an empty SpecDiffs

func (*SpecAnalyser) Analyse Uses

func (sd *SpecAnalyser) Analyse(spec1, spec2 *spec.Swagger) error

Analyse the differences in two specs

func (*SpecAnalyser) CheckNumericTypeChanges Uses

func (sd *SpecAnalyser) CheckNumericTypeChanges(diffs []TypeDiff, type1, type2 spec.SchemaProps) []TypeDiff

CheckNumericTypeChanges checks for changes to or from a numeric type

func (*SpecAnalyser) CheckStringTypeChanges Uses

func (sd *SpecAnalyser) CheckStringTypeChanges(diffs []TypeDiff, type1, type2 spec.SchemaProps) []TypeDiff

CheckStringTypeChanges checks for changes to or from a string type

func (*SpecAnalyser) CheckToFromArrayType Uses

func (sd *SpecAnalyser) CheckToFromArrayType(diffs []TypeDiff, type1, type2 spec.SchemaProps) []TypeDiff

CheckToFromArrayType check for changes to or from an Array type

func (*SpecAnalyser) CheckToFromPrimitiveType Uses

func (sd *SpecAnalyser) CheckToFromPrimitiveType(diffs []TypeDiff, type1, type2 spec.SchemaProps) []TypeDiff

CheckToFromPrimitiveType check for diff to or from a primitive

func (*SpecAnalyser) CompareTypes Uses

func (sd *SpecAnalyser) CompareTypes(type1, type2 spec.SchemaProps) []TypeDiff

CompareTypes computes type specific property diffs

type SpecChangeCode Uses

type SpecChangeCode int

SpecChangeCode enumerates the various types of diffs from one spec to another

const (
    // NoChangeDetected - the specs have no changes
    NoChangeDetected SpecChangeCode = iota
    // DeletedProperty - A message property has been deleted in the new spec
    DeletedProperty
    // AddedProperty - A message property has been added in the new spec
    AddedProperty
    // AddedRequiredProperty - A required message property has been added in the new spec
    AddedRequiredProperty
    // DeletedOptionalParam - An endpoint parameter has been deleted in the new spec
    DeletedOptionalParam
    // ChangedDescripton - Changed a description
    ChangedDescripton
    // AddedDescripton - Added a description
    AddedDescripton
    // DeletedDescripton - Deleted a description
    DeletedDescripton
    // ChangedTag - Changed a tag
    ChangedTag
    // AddedTag - Added a tag
    AddedTag
    // DeletedTag - Deleted a tag
    DeletedTag
    // DeletedResponse - An endpoint response has been deleted in the new spec
    DeletedResponse
    // DeletedEndpoint - An endpoint has been deleted in the new spec
    DeletedEndpoint
    // DeletedDeprecatedEndpoint - A deprecated endpoint has been deleted in the new spec
    DeletedDeprecatedEndpoint
    // AddedRequiredParam - A required parameter has been added in the new spec
    AddedRequiredParam
    // DeletedRequiredParam - A required parameter has been deleted in the new spec
    DeletedRequiredParam
    // ChangedRequiredToOptional - A required parameter has been made optional in the new spec
    ChangedRequiredToOptional
    // AddedEndpoint - An endpoint has been added in the new spec
    AddedEndpoint
    // WidenedType - An type has been changed to a more permissive type eg int->string
    WidenedType
    // NarrowedType - An type has been changed to a less permissive type eg string->int
    NarrowedType
    // ChangedToCompatibleType - An type has been changed to a compatible type eg password->string
    ChangedToCompatibleType
    // ChangedType - An type has been changed to a type whose relative compatibility cannot be determined
    ChangedType
    // AddedEnumValue - An enum type has had a new potential value added to it
    AddedEnumValue
    // DeletedEnumValue - An enum type has had a existing value removed from it
    DeletedEnumValue
    // AddedOptionalParam - A new optional parameter has been added to the new spec
    AddedOptionalParam
    // ChangedOptionalToRequiredParam - An optional parameter is now required in the new spec
    ChangedOptionalToRequiredParam
    // ChangedRequiredToOptionalParam - An required parameter is now optional in the new spec
    ChangedRequiredToOptionalParam
    // AddedResponse An endpoint has new response code in the new spec
    AddedResponse
    // AddedConsumesFormat - a new consumes format (json/xml/yaml etc) has been added in the new spec
    AddedConsumesFormat
    // DeletedConsumesFormat - an existing format has been removed in the new spec
    DeletedConsumesFormat
    // AddedProducesFormat - a new produces format (json/xml/yaml etc) has been added in the new spec
    AddedProducesFormat
    // DeletedProducesFormat - an existing produces format has been removed in the new spec
    DeletedProducesFormat
    // AddedSchemes - a new scheme has been added to the new spec
    AddedSchemes
    // DeletedSchemes - a scheme has been removed from the new spec
    DeletedSchemes
    // ChangedHostURL - the host url has been changed. If this is used in the client generation, then clients will break.
    ChangedHostURL
    // ChangedBasePath - the host base path has been changed. If this is used in the client generation, then clients will break.
    ChangedBasePath
    // AddedResponseHeader Added a header Item
    AddedResponseHeader
    // ChangedResponseHeader Added a header Item
    ChangedResponseHeader
    // DeletedResponseHeader Added a header Item
    DeletedResponseHeader
)

func (*SpecChangeCode) Description Uses

func (s *SpecChangeCode) Description() (result string)

Description returns an english version of this error

func (*SpecChangeCode) MarshalJSON Uses

func (s *SpecChangeCode) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (*SpecChangeCode) UnmarshalJSON Uses

func (s *SpecChangeCode) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashalls a quoted json string to the enum value

type SpecDifference Uses

type SpecDifference struct {
    DifferenceLocation DifferenceLocation `json:"location"`
    Code               SpecChangeCode     `json:"code"`
    Compatibility      Compatibility      `json:"compatibility"`
    DiffInfo           string             `json:"info,omitempty"`
}

SpecDifference encapsulates the details of an individual diff in part of a spec

func (SpecDifference) Matches Uses

func (sd SpecDifference) Matches(other SpecDifference) bool

Matches returns true if the diff matches another

func (SpecDifference) String Uses

func (sd SpecDifference) String() string

String std string renderer

type SpecDifferences Uses

type SpecDifferences []SpecDifference

SpecDifferences list of differences

func Compare Uses

func Compare(spec1, spec2 *spec.Swagger) (diffs SpecDifferences, err error)

Compare returns the result of analysing breaking and non breaking changes between to Swagger specs

func (SpecDifferences) BreakingChangeCount Uses

func (sd SpecDifferences) BreakingChangeCount() int

BreakingChangeCount Calculates the breaking change count

func (SpecDifferences) Contains Uses

func (sd SpecDifferences) Contains(diff SpecDifference) bool

Contains Returns true if the item contains the specified item

func (SpecDifferences) FilterIgnores Uses

func (sd SpecDifferences) FilterIgnores(ignores SpecDifferences) SpecDifferences

FilterIgnores returns a copy of the list without the items in the specified ignore list

func (SpecDifferences) ReportAllDiffs Uses

func (sd SpecDifferences) ReportAllDiffs(fmtJSON bool) error

ReportAllDiffs lists all the diffs between two specs

func (*SpecDifferences) ReportCompatibility Uses

func (sd *SpecDifferences) ReportCompatibility() error

ReportCompatibility lists and spec

type TypeDiff Uses

type TypeDiff struct {
    Change      SpecChangeCode `json:"change-type,omitempty"`
    Description string         `json:"description,omitempty"`
    FromType    string         `json:"from-type,omitempty"`
    ToType      string         `json:"to-type,omitempty"`
}

TypeDiff - describes a primitive type change

type URLMethod Uses

type URLMethod struct {
    Path   string `json:"path"`
    Method string `json:"method"`
}

URLMethod - combines url and method into a single keyed entity

func (URLMethod) MarshalText Uses

func (p URLMethod) MarshalText() (text []byte, err error)

MarshalText - for serializing as a map key

type URLMethodResponse Uses

type URLMethodResponse struct {
    Path     string `json:"path"`
    Method   string `json:"method"`
    Response string `json:"response"`
}

URLMethodResponse encapsulates these three elements to act as a map key

type URLMethods Uses

type URLMethods map[URLMethod]*PathItemOp

URLMethods allows iteration of endpoints based on url and method

Package diff imports 8 packages (graph) and is imported by 2 packages. Updated 2019-06-21. Refresh now. Tools for package owners.