report

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package report generates OpenAPI Spec diff reports as text and HTML. Note that the reports only display the common kinds of changes. For a comprehensive diff report, view the YAML output of the diff.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHTMLReportAsString

func GetHTMLReportAsString(d *diff.Diff) (string, error)

GetHTMLReportAsString returns an HTML diff report as a string

Example
package main

import (
	"fmt"

	"github.com/getkin/kin-openapi/openapi3"
	"github.com/tufin/oasdiff/diff"
	"github.com/tufin/oasdiff/report"
)

func main() {
	swaggerLoader := openapi3.NewSwaggerLoader()
	swaggerLoader.IsExternalRefsAllowed = true

	s1, err := swaggerLoader.LoadSwaggerFromFile("../../data/openapi-test1.yaml")
	if err != nil {
		fmt.Printf("failed to load spec with %v", err)
		return
	}

	s2, err := swaggerLoader.LoadSwaggerFromFile("../../data/openapi-test3.yaml")
	if err != nil {
		fmt.Printf("failed to load spec with %v", err)
		return
	}

	diffReport, err := diff.Get(&diff.Config{}, s1, s2)
	if err != nil {
		fmt.Printf("diff failed with %v", err)
		return
	}

	html, err := report.GetHTMLReportAsString(diffReport)
	if err != nil {
		fmt.Printf("failed to generate HTML with %v", err)
		return
	}

	fmt.Print(html)
}

func GetTextReportAsBytes

func GetTextReportAsBytes(d *diff.Diff) []byte

GetTextReportAsBytes returns a textual diff report as bytes The report is compatible with Github markdown

func GetTextReportAsString

func GetTextReportAsString(d *diff.Diff) string

GetTextReportAsString returns a textual diff report as a string The report is compatible with Github markdown

Example
package main

import (
	"fmt"

	"github.com/getkin/kin-openapi/openapi3"
	"github.com/tufin/oasdiff/diff"
	"github.com/tufin/oasdiff/report"
)

func main() {
	swaggerLoader := openapi3.NewSwaggerLoader()
	swaggerLoader.IsExternalRefsAllowed = true

	s1, err := swaggerLoader.LoadSwaggerFromFile("../../data/openapi-test1.yaml")
	if err != nil {
		fmt.Printf("failed to load spec with %v", err)
		return
	}

	s2, err := swaggerLoader.LoadSwaggerFromFile("../../data/openapi-test3.yaml")
	if err != nil {
		fmt.Printf("failed to load spec with %v", err)
		return
	}

	diffReport, err := diff.Get(&diff.Config{}, s1, s2)
	if err != nil {
		fmt.Printf("diff failed with %v", err)
		return
	}

	fmt.Print(report.GetTextReportAsString(diffReport))
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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