{"modulePath":"github.com/go-openapi/analysis","version":"v1.0.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package diff\n\n## Constants\n\n```go\nconst (\n\tErrDiff diffError = \"diff error\"\n)\n```\n\n```go\nconst StringType = \"string\"\n```\nStringType For identifying string types.\n\n## Variables\n\n```go\nvar ArrayType = \"array\" //nolint:gochecknoglobals // quasi-constant used across package\n\n```\nArrayType const for array.\n\n```go\nvar ObjectType = \"object\" //nolint:gochecknoglobals // quasi-constant used across package\n\n```\nObjectType const for object.\n\n## Functions\n\n```go\nfunc JSONMarshal(t any) ([]byte, error)\n```\nJSONMarshal allows the item to be correctly rendered to json.\n\n## Types\n\n```go\ntype CompareSchemaFn func(location DifferenceLocation, schema1, schema2 *spec.Schema)\n```\nCompareSchemaFn Fn spec for comparing schemas.\n\n```go\ntype Compatibility int\n```\nCompatibility - whether this is a breaking or non-breaking change.\n\n```go\nconst (\n\t// Breaking this change could break existing clients.\n\tBreaking Compatibility = iota\n\t// NonBreaking This is a backwards-compatible API change.\n\tNonBreaking\n\t// Warning changes are technically non-breaking but can cause behavior changes in client and thus should be reported differently.\n\tWarning\n)\n```\n\n```go\nfunc (s Compatibility) MarshalJSON() ([]byte, error)\n```\nMarshalJSON marshals the enum as a quoted json string.\n\n```go\nfunc (s Compatibility) String() string\n```\n\n```go\nfunc (s *Compatibility) UnmarshalJSON(b []byte) error\n```\nUnmarshalJSON unmashals a quoted json string to the enum value.\n\n```go\ntype CompatibilityPolicy struct {\n\tForResponse map[SpecChangeCode]Compatibility\n\tForRequest  map[SpecChangeCode]Compatibility\n\tForChange   map[SpecChangeCode]Compatibility\n}\n```\nCompatibilityPolicy decides which changes are breaking and which are not.\n\n```go\ntype DataDirection int\n```\nDataDirection indicates the direction of change Request vs Response.\n\n```go\nconst (\n\t// Request Used for messages/param diffs in a request.\n\tRequest DataDirection = iota\n\t// Response Used for messages/param diffs in a response.\n\tResponse\n)\n```\n\n```go\ntype DifferenceLocation struct {\n\tURL      string `json:\"url\"`\n\tMethod   string `json:\"method,omitempty\"`\n\tResponse int    `json:\"response,omitempty\"`\n\tNode     *Node  `json:\"node,omitempty\"`\n}\n```\nDifferenceLocation indicates where the difference occurs.\n\n```go\nfunc (dl DifferenceLocation) AddNode(node *Node) DifferenceLocation\n```\nAddNode returns a copy of this location with the leaf node added.\n\n```go\ntype Node struct {\n\tField     string `json:\"name,omitempty\"`\n\tTypeName  string `json:\"type,omitempty\"`\n\tIsArray   bool   `json:\"is_array,omitempty\"`\n\tChildNode *Node  `json:\"child,omitempty\"`\n}\n```\nNode is the position od a diff in a spec.\n\n```go\nfunc (n *Node) AddLeafNode(toAdd *Node) *Node\n```\nAddLeafNode Adds (recursive) a Child to the first non-nil child found.\n\n```go\nfunc (n Node) Copy() *Node\n```\nCopy deep copy of this node and children.\n\n```go\nfunc (n *Node) String() string\n```\nString std string render.\n\n```go\ntype OperationMap map[string]*spec.Operation\n```\nOperationMap saves indexing operations in PathItems individually.\n\n```go\ntype Pair struct {\n\tFirst  any\n\tSecond any\n}\n```\nPair stores a pair of items which share a key in two maps.\n\n```go\ntype PathItemOp struct {\n\tParentPathItem *spec.PathItem  `json:\"pathitem\"`\n\tOperation      *spec.Operation `json:\"operation\"`\n\tExtensions     spec.Extensions `json:\"extensions\"`\n}\n```\nPathItemOp - combines path and operation into a single keyed entity.\n\n```go\ntype PropertyDefn struct {\n\tSchema   *spec.Schema\n\tRequired bool\n}\n```\nPropertyDefn combines a property with its required-ness.\n\n```go\ntype PropertyMap map[string]PropertyDefn\n```\nPropertyMap a unified map including all AllOf fields.\n\n```go\ntype SchemaFromRefFn func(spec.Ref) (*spec.Schema, string)\n```\nSchemaFromRefFn define this to get a schema for a ref.\n\n```go\ntype SpecAnalyser struct {\n\tDiffs SpecDifferences\n\n\tDefinitions1          spec.Definitions\n\tDefinitions2          spec.Definitions\n\tInfo1                 *spec.Info\n\tInfo2                 *spec.Info\n\tReferencedDefinitions map[string]bool\n\t// contains filtered or unexported fields\n}\n```\nSpecAnalyser contains all the differences for a Spec.\n\n```go\nfunc NewSpecAnalyser() *SpecAnalyser\n```\nNewSpecAnalyser returns an empty SpecDiffs.\n\n```go\nfunc (sd *SpecAnalyser) Analyse(spec1, spec2 *spec.Swagger) error\n```\nAnalyse the differences in two specs.\n\n```go\nfunc (sd *SpecAnalyser) AnalyseDefinitions()\n```\nAnalyseDefinitions check for changes to definition objects not referenced in any endpoint.\n\n```go\nfunc (sd *SpecAnalyser) CompareProps(type1, type2 *spec.SchemaProps) []TypeDiff\n```\nCompareProps computes type specific property diffs.\n\n```go\ntype SpecChangeCode int\n```\nSpecChangeCode enumerates the various types of diffs from one spec to another.\n\n```go\nconst (\n\t// NoChangeDetected - the specs have no changes.\n\tNoChangeDetected SpecChangeCode = iota\n\t// DeletedProperty - A message property has been deleted in the new spec.\n\tDeletedProperty\n\t// AddedProperty - A message property has been added in the new spec.\n\tAddedProperty\n\t// AddedRequiredProperty - A required message property has been added in the new spec.\n\tAddedRequiredProperty\n\t// DeletedOptionalParam - An endpoint parameter has been deleted in the new spec.\n\tDeletedOptionalParam\n\t// ChangedDescription - Changed a description.\n\tChangedDescription\n\t// AddedDescription - Added a description.\n\tAddedDescription\n\t// DeletedDescription - Deleted a description.\n\tDeletedDescription\n\t// ChangedTag - Changed a tag.\n\tChangedTag\n\t// AddedTag - Added a tag.\n\tAddedTag\n\t// DeletedTag - Deleted a tag.\n\tDeletedTag\n\t// DeletedResponse - An endpoint response has been deleted in the new spec.\n\tDeletedResponse\n\t// DeletedEndpoint - An endpoint has been deleted in the new spec.\n\tDeletedEndpoint\n\t// DeletedDeprecatedEndpoint - A deprecated endpoint has been deleted in the new spec.\n\tDeletedDeprecatedEndpoint\n\t// AddedRequiredParam - A required parameter has been added in the new spec.\n\tAddedRequiredParam\n\t// DeletedRequiredParam - A required parameter has been deleted in the new spec.\n\tDeletedRequiredParam\n\t// AddedEndpoint - An endpoint has been added in the new spec.\n\tAddedEndpoint\n\t// WidenedType - An type has been changed to a more permissive type eg int-\u003estring.\n\tWidenedType\n\t// NarrowedType - An type has been changed to a less permissive type eg string-\u003eint.\n\tNarrowedType\n\t// ChangedToCompatibleType - An type has been changed to a compatible type eg password-\u003estring.\n\tChangedToCompatibleType\n\t// ChangedType - An type has been changed to a type whose relative compatibility cannot be determined.\n\tChangedType\n\t// AddedEnumValue - An enum type has had a new potential value added to it.\n\tAddedEnumValue\n\t// DeletedEnumValue - An enum type has had a existing value removed from it.\n\tDeletedEnumValue\n\t// AddedOptionalParam - A new optional parameter has been added to the new spec.\n\tAddedOptionalParam\n\t// ChangedOptionalToRequired - An optional parameter is now required in the new spec.\n\tChangedOptionalToRequired\n\t// ChangedRequiredToOptional - An required parameter is now optional in the new spec.\n\tChangedRequiredToOptional\n\t// AddedResponse An endpoint has new response code in the new spec.\n\tAddedResponse\n\t// AddedConsumesFormat - a new consumes format (json/xml/yaml etc) has been added in the new spec.\n\tAddedConsumesFormat\n\t// DeletedConsumesFormat - an existing format has been removed in the new spec.\n\tDeletedConsumesFormat\n\t// AddedProducesFormat - a new produces format (json/xml/yaml etc) has been added in the new spec.\n\tAddedProducesFormat\n\t// DeletedProducesFormat - an existing produces format has been removed in the new spec.\n\tDeletedProducesFormat\n\t// AddedSchemes - a new scheme has been added to the new spec.\n\tAddedSchemes\n\t// DeletedSchemes - a scheme has been removed from the new spec.\n\tDeletedSchemes\n\t// ChangedHostURL - the host url has been changed. If this is used in the client generation, then clients will break.\n\tChangedHostURL\n\t// ChangedBasePath - the host base path has been changed. If this is used in the client generation, then clients will break.\n\tChangedBasePath\n\t// AddedResponseHeader Added a header Item.\n\tAddedResponseHeader\n\t// ChangedResponseHeader Added a header Item.\n\tChangedResponseHeader\n\t// DeletedResponseHeader Added a header Item.\n\tDeletedResponseHeader\n\t// RefTargetChanged Changed a ref to point to a different object.\n\tRefTargetChanged\n\t// RefTargetRenamed Renamed a ref to point to the same object.\n\tRefTargetRenamed\n\t// DeletedConstraint Deleted a schema constraint.\n\tDeletedConstraint\n\t// AddedConstraint Added a schema constraint.\n\tAddedConstraint\n\t// DeletedDefinition removed one of the definitions.\n\tDeletedDefinition\n\t// AddedDefinition removed one of the definitions.\n\tAddedDefinition\n\t// ChangedDefault - Changed default value.\n\tChangedDefault\n\t// AddedDefault - Added a default value.\n\tAddedDefault\n\t// DeletedDefault - Deleted a default value.\n\tDeletedDefault\n\t// ChangedExample - Changed an example value.\n\tChangedExample\n\t// AddedExample - Added an example value.\n\tAddedExample\n\t// DeletedExample - Deleted an example value.\n\tDeletedExample\n\t// ChangedCollectionFormat - A collectionFormat has been changed to a collectionFormat whose relative compatibility cannot be determined.\n\tChangedCollectionFormat\n\t// DeletedExtension deleted an extension.\n\tDeletedExtension\n\t// AddedExtension added an extension.\n\tAddedExtension\n\t// ChangedExtensionValue changed an extension value.\n\tChangedExtensionValue\n)\n```\n\n```go\nfunc (s SpecChangeCode) Description() (result string)\n```\nDescription returns an english version of this error.\n\n```go\nfunc (s SpecChangeCode) MarshalJSON() ([]byte, error)\n```\nMarshalJSON marshals the enum as a quoted json string.\n\n```go\nfunc (s *SpecChangeCode) UnmarshalJSON(b []byte) error\n```\nUnmarshalJSON unmashalls a quoted json string to the enum value.\n\n```go\ntype SpecDifference struct {\n\tDifferenceLocation DifferenceLocation `json:\"location\"`\n\tCode               SpecChangeCode     `json:\"code\"`\n\tCompatibility      Compatibility      `json:\"compatibility\"`\n\tDiffInfo           string             `json:\"info,omitempty\"`\n}\n```\nSpecDifference encapsulates the details of an individual diff in part of a spec.\n\n```go\nfunc CompareProperties(\n\tlocation DifferenceLocation,\n\tschema1, schema2 *spec.Schema,\n\tgetRefFn1, getRefFn2 SchemaFromRefFn,\n\tcmp CompareSchemaFn,\n) []SpecDifference\n```\nCompareProperties recursive property comparison.\n\n```go\nfunc (sd SpecDifference) Matches(other SpecDifference) bool\n```\nMatches returns true if the diff matches another.\n\n```go\nfunc (sd SpecDifference) String() string\n```\nString std string renderer.\n\n```go\ntype SpecDifferences []SpecDifference\n```\nSpecDifferences list of differences.\n\n```go\nfunc Compare(spec1, spec2 *spec.Swagger) (diffs SpecDifferences, err error)\n```\nCompare returns the result of analysing breaking and non breaking changes between to Swagger specs.\n\n```go\nfunc (sd SpecDifferences) BreakingChangeCount() int\n```\nBreakingChangeCount Calculates the breaking change count.\n\n```go\nfunc (sd SpecDifferences) Contains(diff SpecDifference) bool\n```\nContains Returns true if the item contains the specified item.\n\n```go\nfunc (sd SpecDifferences) FilterIgnores(ignores SpecDifferences) SpecDifferences\n```\nFilterIgnores returns a copy of the list without the items in the specified ignore list.\n\n```go\nfunc (sd SpecDifferences) ReportAllDiffs(fmtJSON bool) (io.Reader, error, error)\n```\nReportAllDiffs lists all the diffs between two specs.\n\n```go\nfunc (sd *SpecDifferences) ReportCompatibility() (io.Reader, error, error)\n```\nReportCompatibility lists and spec.\n\n```go\nfunc (sd SpecDifferences) WarningChangeCount() int\n```\nWarningChangeCount Calculates the warning change count.\n\n```go\ntype TypeDiff struct {\n\tChange      SpecChangeCode `json:\"change_type,omitempty\"`\n\tDescription string         `json:\"description,omitempty\"`\n\tFromType    string         `json:\"from_type,omitempty\"`\n\tToType      string         `json:\"to_type,omitempty\"`\n}\n```\nTypeDiff - describes a primitive type change.\n\n```go\nfunc CheckRefChange(diffs []TypeDiff, type1, type2 any) (diffReturn []TypeDiff)\n```\nCheckRefChange has the property ref changed.\n\n```go\nfunc CheckStringTypeChanges(diffs []TypeDiff, type1, type2 *spec.SchemaProps) []TypeDiff\n```\nCheckStringTypeChanges checks for changes to or from a string type.\n\n```go\nfunc CheckToFromPrimitiveType(diffs []TypeDiff, type1, type2 any) []TypeDiff\n```\nCheckToFromPrimitiveType check for diff to or from a primitive.\n\n```go\nfunc CheckToFromRequired(required1, required2 bool) (diffs []TypeDiff)\n```\nCheckToFromRequired checks for changes to or from a required property.\n\n```go\nfunc CompareEnums(left, right []any) []TypeDiff\n```\nCompareEnums returns added, deleted enum values.\n\n```go\nfunc CompareFloatValues(fieldName string, val1 *float64, val2 *float64, ifGreaterCode SpecChangeCode, ifLessCode SpecChangeCode) []TypeDiff\n```\nCompareFloatValues compares a float data item.\n\n```go\nfunc CompareIntValues(fieldName string, val1 *int64, val2 *int64, ifGreaterCode SpecChangeCode, ifLessCode SpecChangeCode) []TypeDiff\n```\nCompareIntValues compares to int data items.\n\n```go\ntype URLMethod struct {\n\tPath   string `json:\"path\"`\n\tMethod string `json:\"method\"`\n}\n```\nURLMethod - combines url and method into a single keyed entity.\n\n```go\nfunc (p URLMethod) MarshalText() (text []byte, err error)\n```\nMarshalText - for serializing as a map key.\n\n```go\ntype URLMethodResponse struct {\n\tPath     string `json:\"path\"`\n\tMethod   string `json:\"method\"`\n\tResponse string `json:\"response\"`\n}\n```\nURLMethodResponse encapsulates these three elements to act as a map key.\n\n```go\ntype URLMethods map[URLMethod]*PathItemOp\n```\nURLMethods allows iteration of endpoints based on url and method.\n\n","path":"github.com/go-openapi/analysis/diff","name":"diff","synopsis":"","isRedistributable":true}
