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 ¶
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() {
loader := openapi3.NewLoader()
loader.IsExternalRefsAllowed = true
s1, err := loader.LoadFromFile("../../data/openapi-test1.yaml")
if err != nil {
fmt.Printf("failed to load spec with %v", err)
return
}
s2, err := loader.LoadFromFile("../../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)
}
Output:
func GetTextReportAsBytes ¶
GetTextReportAsBytes returns a textual diff report as bytes The report is compatible with Github markdown
func GetTextReportAsString ¶
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.NewLoader()
swaggerLoader.IsExternalRefsAllowed = true
s1, err := swaggerLoader.LoadFromFile("../../data/openapi-test1.yaml")
if err != nil {
fmt.Printf("failed to load spec with %v", err)
return
}
s2, err := swaggerLoader.LoadFromFile("../../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))
}
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.