formatters

package
v1.10.27 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteHtmlTemplate added in v1.10.23

func ExecuteHtmlTemplate(tmpl *template.Template, changes ChangesByEndpoint, specInfoPair *load.SpecInfoPair) ([]byte, error)

func ExecuteTextTemplate added in v1.10.23

func ExecuteTextTemplate(tmpl *template.Template, changes ChangesByEndpoint, specInfoPair *load.SpecInfoPair) ([]byte, error)

func GetSupportedFormats added in v1.10.24

func GetSupportedFormats() []string

func SupportedFormatsByContentType

func SupportedFormatsByContentType(output Output) []string

Types

type Change added in v1.10.0

type Change struct {
	Id          string         `json:"id,omitempty" yaml:"id,omitempty"`
	Text        string         `json:"text,omitempty" yaml:"text,omitempty"`
	Comment     string         `json:"comment,omitempty" yaml:"comment,omitempty"`
	Level       checker.Level  `json:"level" yaml:"level"`
	Operation   string         `json:"operation,omitempty" yaml:"operation,omitempty"`
	OperationId string         `json:"operationId,omitempty" yaml:"operationId,omitempty"`
	Path        string         `json:"path,omitempty" yaml:"path,omitempty"`
	Source      string         `json:"source,omitempty" yaml:"source,omitempty"`
	Section     string         `json:"section,omitempty" yaml:"section,omitempty"`
	IsBreaking  bool           `json:"-" yaml:"-"`
	Attributes  map[string]any `json:"attributes,omitempty" yaml:"attributes,omitempty"`
}

type Changes added in v1.10.0

type Changes []Change

func NewChanges added in v1.10.0

func NewChanges(originalChanges checker.Changes, l checker.Localizer) Changes

type ChangesByEndpoint added in v1.10.0

type ChangesByEndpoint map[Endpoint]*Changes

func GroupChanges added in v1.10.0

func GroupChanges(changes checker.Changes, l checker.Localizer) ChangesByEndpoint

type Check

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

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 Endpoint added in v1.10.0

type Endpoint struct {
	Path      string
	Operation string
}

type Format

type Format string
const (
	FormatYAML          Format = "yaml"
	FormatJSON          Format = "json"
	FormatText          Format = "text"
	FormatMarkup        Format = "markup"
	FormatSingleLine    Format = "singleline"
	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)
	RenderChangelog(changes checker.Changes, opts RenderOpts, specInfoPair *load.SpecInfoPair) ([]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 {
	Localizer checker.Localizer
	// contains filtered or unexported fields
}

func (GitHubActionsFormatter) RenderChangelog

func (f GitHubActionsFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts, specInfoPair *load.SpecInfoPair) ([]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 {
	Localizer checker.Localizer
	// contains filtered or unexported fields
}

func (HTMLFormatter) RenderChangelog

func (f HTMLFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts, specInfoPair *load.SpecInfoPair) ([]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 {
	Localizer checker.Localizer
}

func (JSONFormatter) RenderChangelog

func (f JSONFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts, specInfoPair *load.SpecInfoPair) ([]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 {
	Localizer checker.Localizer
	// contains filtered or unexported fields
}

func (JUnitFormatter) RenderChangelog

func (f JUnitFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts, specInfoPair *load.SpecInfoPair) ([]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 MarkupFormatter added in v1.10.23

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

func (MarkupFormatter) RenderChangelog added in v1.10.23

func (f MarkupFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts, specInfoPair *load.SpecInfoPair) ([]byte, error)

func (MarkupFormatter) RenderChecks added in v1.10.23

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

func (MarkupFormatter) RenderDiff added in v1.10.23

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

func (MarkupFormatter) RenderFlatten added in v1.10.23

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

func (MarkupFormatter) RenderSummary added in v1.10.23

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

func (MarkupFormatter) SupportedOutputs added in v1.10.23

func (f MarkupFormatter) SupportedOutputs() []Output

type Output

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

type RenderOpts

type RenderOpts struct {
	ColorMode checker.ColorMode
}

RenderOpts can be used to pass properties to the renderer method

func NewRenderOpts added in v1.10.0

func NewRenderOpts() RenderOpts

type SingleLineFormatter added in v1.10.0

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

func (SingleLineFormatter) RenderChangelog added in v1.10.0

func (f SingleLineFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts, specInfoPair *load.SpecInfoPair) ([]byte, error)

func (SingleLineFormatter) RenderChecks added in v1.10.0

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

func (SingleLineFormatter) RenderDiff added in v1.10.0

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

func (SingleLineFormatter) RenderFlatten added in v1.10.0

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

func (SingleLineFormatter) RenderSummary added in v1.10.0

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

func (SingleLineFormatter) SupportedOutputs added in v1.10.0

func (f SingleLineFormatter) SupportedOutputs() []Output

type TEXTFormatter

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

func (TEXTFormatter) RenderChangelog

func (f TEXTFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts, specInfoPair *load.SpecInfoPair) ([]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 TemplateData added in v1.9.6

type TemplateData struct {
	APIChanges      ChangesByEndpoint
	BaseVersion     string
	RevisionVersion string
}

type YAMLFormatter

type YAMLFormatter struct {
	Localizer checker.Localizer
}

func (YAMLFormatter) RenderChangelog

func (f YAMLFormatter) RenderChangelog(changes checker.Changes, opts RenderOpts, specInfoPair *load.SpecInfoPair) ([]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