formatters

package
v1.9.5-beta Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StripANSIEscapeCodes

func StripANSIEscapeCodes(data []byte) []byte

StripANSIEscapeCodes removes ANSI escape codes TODO: remove this function once there is a better way to prevent ANSI escape codes in messages for json/yaml output

func StripANSIEscapeCodesStr

func StripANSIEscapeCodesStr(data string) string

StripANSIEscapeCodesStr removes ANSI escape codes TODO: remove this function once there is a better way to prevent ANSI escape codes in messages for json/yaml output

func SupportedFormatsByContentType

func SupportedFormatsByContentType(output Output) []string

Types

type Check

type Check struct {
	Id          string `json:"id" yaml:"id"`
	Level       string `json:"level" yaml:"level"`
	Description string `json:"description" yaml:"description"`
	Required    bool   `json:"reuired" yaml:"reuired"`
}

type Checks added in v1.9.3

type Checks []Check

func (Checks) Len added in v1.9.3

func (checks Checks) Len() int

func (Checks) Less added in v1.9.3

func (checks Checks) Less(i, j int) bool

func (Checks) Swap added in v1.9.3

func (checks Checks) Swap(i, j int)

type Format

type Format string
const (
	FormatYAML          Format = "yaml"
	FormatJSON          Format = "json"
	FormatText          Format = "text"
	FormatHTML          Format = "html"
	FormatGithubActions Format = "githubactions"
	FormatJUnit         Format = "junit"
	FormatSarif         Format = "sarif"
)

type Formatter

type Formatter interface {
	RenderDiff(diff *diff.Diff, opts RenderOpts) ([]byte, error)
	RenderSummary(diff *diff.Diff, opts RenderOpts) ([]byte, error)
	RenderBreakingChanges(changes checker.Changes, opts RenderOpts) ([]byte, error)
	RenderChangelog(changes checker.Changes, opts RenderOpts) ([]byte, error)
	RenderChecks(checks Checks, opts RenderOpts) ([]byte, error)
	RenderFlatten(spec *openapi3.T, opts RenderOpts) ([]byte, error)
	SupportedOutputs() []Output
}

Formatter is a common interface for output formatters

func Lookup

func Lookup(format string, opts FormatterOpts) (Formatter, error)

Lookup returns a formatter by its name

type FormatterOpts

type FormatterOpts struct {
	Language string
}

FormatterOpts can be used to pass properties to the formatter (e.g. colors)

func DefaultFormatterOpts

func DefaultFormatterOpts() FormatterOpts

DefaultFormatterOpts returns the default formatter options (e.g. colors, CI mode, etc.)

type GitHubActionsFormatter

type GitHubActionsFormatter struct {
	// contains filtered or unexported fields
}

func (GitHubActionsFormatter) RenderBreakingChanges

func (f GitHubActionsFormatter) RenderBreakingChanges(changes checker.Changes, opts RenderOpts) ([]byte, error)

func (GitHubActionsFormatter) RenderChangelog

func (f GitHubActionsFormatter) RenderChangelog(checker.Changes, RenderOpts) ([]byte, error)

func (GitHubActionsFormatter) RenderChecks

func (f GitHubActionsFormatter) RenderChecks(Checks, RenderOpts) ([]byte, error)

func (GitHubActionsFormatter) RenderDiff

func (f GitHubActionsFormatter) RenderDiff(*diff.Diff, RenderOpts) ([]byte, error)

func (GitHubActionsFormatter) RenderFlatten

func (f GitHubActionsFormatter) RenderFlatten(*openapi3.T, RenderOpts) ([]byte, error)

func (GitHubActionsFormatter) RenderSummary

func (f GitHubActionsFormatter) RenderSummary(*diff.Diff, RenderOpts) ([]byte, error)

func (GitHubActionsFormatter) SupportedOutputs

func (f GitHubActionsFormatter) SupportedOutputs() []Output

type HTMLFormatter

type HTMLFormatter struct {
	// contains filtered or unexported fields
}

func (HTMLFormatter) RenderBreakingChanges

func (f HTMLFormatter) RenderBreakingChanges(checker.Changes, RenderOpts) ([]byte, error)

func (HTMLFormatter) RenderChangelog

func (f HTMLFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts) ([]byte, error)

func (HTMLFormatter) RenderChecks

func (f HTMLFormatter) RenderChecks(Checks, RenderOpts) ([]byte, error)

func (HTMLFormatter) RenderDiff

func (f HTMLFormatter) RenderDiff(diff *diff.Diff, opts RenderOpts) ([]byte, error)

func (HTMLFormatter) RenderFlatten

func (f HTMLFormatter) RenderFlatten(*openapi3.T, RenderOpts) ([]byte, error)

func (HTMLFormatter) RenderSummary

func (f HTMLFormatter) RenderSummary(*diff.Diff, RenderOpts) ([]byte, error)

func (HTMLFormatter) SupportedOutputs

func (f HTMLFormatter) SupportedOutputs() []Output

type JSONFormatter

type JSONFormatter struct {
}

func (JSONFormatter) RenderBreakingChanges

func (f JSONFormatter) RenderBreakingChanges(changes checker.Changes, opts RenderOpts) ([]byte, error)

func (JSONFormatter) RenderChangelog

func (f JSONFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts) ([]byte, error)

func (JSONFormatter) RenderChecks

func (f JSONFormatter) RenderChecks(checks Checks, opts RenderOpts) ([]byte, error)

func (JSONFormatter) RenderDiff

func (f JSONFormatter) RenderDiff(diff *diff.Diff, opts RenderOpts) ([]byte, error)

func (JSONFormatter) RenderFlatten

func (f JSONFormatter) RenderFlatten(spec *openapi3.T, opts RenderOpts) ([]byte, error)

func (JSONFormatter) RenderSummary

func (f JSONFormatter) RenderSummary(diff *diff.Diff, opts RenderOpts) ([]byte, error)

func (JSONFormatter) SupportedOutputs

func (f JSONFormatter) SupportedOutputs() []Output

type JUnitFailure

type JUnitFailure struct {
	Message string `xml:"message,attr"`
	CDATA   string `xml:",innerxml"`
}

type JUnitFormatter

type JUnitFormatter struct {
	// contains filtered or unexported fields
}

func (JUnitFormatter) RenderBreakingChanges

func (f JUnitFormatter) RenderBreakingChanges(changes checker.Changes, opts RenderOpts) ([]byte, error)

func (JUnitFormatter) RenderChangelog

func (f JUnitFormatter) RenderChangelog(checker.Changes, RenderOpts) ([]byte, error)

func (JUnitFormatter) RenderChecks

func (f JUnitFormatter) RenderChecks(Checks, RenderOpts) ([]byte, error)

func (JUnitFormatter) RenderDiff

func (f JUnitFormatter) RenderDiff(*diff.Diff, RenderOpts) ([]byte, error)

func (JUnitFormatter) RenderFlatten

func (f JUnitFormatter) RenderFlatten(*openapi3.T, RenderOpts) ([]byte, error)

func (JUnitFormatter) RenderSummary

func (f JUnitFormatter) RenderSummary(*diff.Diff, RenderOpts) ([]byte, error)

func (JUnitFormatter) SupportedOutputs

func (f JUnitFormatter) SupportedOutputs() []Output

type JUnitTestCase

type JUnitTestCase struct {
	Name      string        `xml:"name,attr"`
	Classname string        `xml:"classname,attr"`
	Time      string        `xml:"time,attr"`
	Failure   *JUnitFailure `xml:"failure,omitempty"`
}

type JUnitTestSuite

type JUnitTestSuite struct {
	XMLName   xml.Name        `xml:"testsuite"`
	Package   string          `xml:"package,attr"`
	Time      string          `xml:"time,attr"`
	Tests     int             `xml:"tests,attr"`
	Errors    int             `xml:"errors,attr"`
	Failures  int             `xml:"failures,attr"`
	Name      string          `xml:"name,attr"`
	TestCases []JUnitTestCase `xml:"testcase"`
}

type JUnitTestSuites

type JUnitTestSuites struct {
	XMLName    xml.Name         `xml:"testsuites"`
	TestSuites []JUnitTestSuite `xml:"testsuites"`
}

type Output

type Output int
const (
	OutputDiff Output = iota
	OutputSummary
	OutputBreaking
	OutputChangelog
	OutputChecks
	OutputFlatten
)

type RenderOpts

type RenderOpts struct {
}

RenderOpts can be used to pass properties to the renderer method

type TEXTFormatter

type TEXTFormatter struct {
	Localizer checker.Localizer
	// contains filtered or unexported fields
}

func (TEXTFormatter) RenderBreakingChanges

func (f TEXTFormatter) RenderBreakingChanges(changes checker.Changes, opts RenderOpts) ([]byte, error)

func (TEXTFormatter) RenderChangelog

func (f TEXTFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts) ([]byte, error)

func (TEXTFormatter) RenderChecks

func (f TEXTFormatter) RenderChecks(checks Checks, opts RenderOpts) ([]byte, error)

func (TEXTFormatter) RenderDiff

func (f TEXTFormatter) RenderDiff(diff *diff.Diff, opts RenderOpts) ([]byte, error)

func (TEXTFormatter) RenderFlatten

func (f TEXTFormatter) RenderFlatten(*openapi3.T, RenderOpts) ([]byte, error)

func (TEXTFormatter) RenderSummary

func (f TEXTFormatter) RenderSummary(*diff.Diff, RenderOpts) ([]byte, error)

func (TEXTFormatter) SupportedOutputs

func (f TEXTFormatter) SupportedOutputs() []Output

type YAMLFormatter

type YAMLFormatter struct {
}

func (YAMLFormatter) RenderBreakingChanges

func (f YAMLFormatter) RenderBreakingChanges(changes checker.Changes, opts RenderOpts) ([]byte, error)

func (YAMLFormatter) RenderChangelog

func (f YAMLFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts) ([]byte, error)

func (YAMLFormatter) RenderChecks

func (f YAMLFormatter) RenderChecks(checks Checks, opts RenderOpts) ([]byte, error)

func (YAMLFormatter) RenderDiff

func (f YAMLFormatter) RenderDiff(diff *diff.Diff, opts RenderOpts) ([]byte, error)

func (YAMLFormatter) RenderFlatten

func (f YAMLFormatter) RenderFlatten(spec *openapi3.T, opts RenderOpts) ([]byte, error)

func (YAMLFormatter) RenderSummary

func (f YAMLFormatter) RenderSummary(diff *diff.Diff, opts RenderOpts) ([]byte, error)

func (YAMLFormatter) SupportedOutputs

func (f YAMLFormatter) SupportedOutputs() []Output

Jump to

Keyboard shortcuts

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