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, _ := os.ReadFile("../test_specs/burgershop.openapi.yaml") // Read in a 'right' (modified) OpenAPI specification modified, _ := os.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.CreateDocumentFromConfig(infoOriginal, datamodel.NewDocumentConfiguration()) modDocDocument, _ := v3.CreateDocumentFromConfig(infoModified, datamodel.NewDocumentConfiguration()) // 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 75 changes, of which 19 are breaking. 6 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.