what_changed

package
v0.4.15 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package what_changed

what changed is a feature that performs an accurate and deep analysis of what has changed between two OpenAPI documents. The report generated outlines every single change made between two specifications (left and right) rendered in the document hierarchy, so exploring it is the same as exploring the document model.

There are two main functions, one of generating a report for Swagger documents (OpenAPI 2) And OpenAPI 3+ documents.

This package uses a combined model for OpenAPI and Swagger changes, it does not break them out into separate versions like the datamodel package. The reason for this is to prevent sprawl across versions and to provide a single API and model for any application that wants to use this feature.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareOpenAPIDocuments added in v0.2.0

func CompareOpenAPIDocuments(original, updated *v3.Document) *model.DocumentChanges

CompareOpenAPIDocuments will compare left (original) and right (updated) OpenAPI 3+ documents and extract every change made across the entire specification. The report outlines every property changed, everything that was added, or removed and which of those changes were breaking.

Example
// Read in a 'left' (original) OpenAPI specification
original, _ := ioutil.ReadFile("../test_specs/burgershop.openapi.yaml")

// Read in a 'right' (modified) OpenAPI specification
modified, _ := ioutil.ReadFile("../test_specs/burgershop.openapi-modified.yaml")

// Extract SpecInfo from bytes
infoOriginal, _ := datamodel.ExtractSpecInfo(original)
infoModified, _ := datamodel.ExtractSpecInfo(modified)

// Build OpenAPI Documents from SpecInfo
origDocument, _ := v3.CreateDocument(infoOriginal)
modDocDocument, _ := v3.CreateDocument(infoModified)

// Compare OpenAPI Documents and extract to *DocumentChanges
changes := CompareOpenAPIDocuments(origDocument, modDocDocument)

// Extract SchemaChanges from components changes.
schemaChanges := changes.ComponentsChanges.SchemaChanges

// Print out some interesting stats.
fmt.Printf("There are %d changes, of which %d are breaking. %v schemas have changes.",
	changes.TotalChanges(), changes.TotalBreakingChanges(), len(schemaChanges))
Output:

There are 67 changes, of which 17 are breaking. 5 schemas have changes.

func CompareSwaggerDocuments added in v0.2.0

func CompareSwaggerDocuments(original, updated *v2.Swagger) *model.DocumentChanges

CompareSwaggerDocuments will compare left (original) and a right (updated) Swagger documents and extract every change made across the entire specification. The report outlines every property changes, everything that was added, or removed and which of those changes were breaking.

Types

This section is empty.

Directories

Path Synopsis
Package model
Package model

Jump to

Keyboard shortcuts

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