formatters

package
v0.0.0-...-b7d109a Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteHtmlTemplate

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

func ExecuteTextTemplate

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

func GetSupportedFormats

func GetSupportedFormats() []string

func SupportedFormatsByContentType

func SupportedFormatsByContentType(output Output) []string

Types

type Change

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

type Changes []Change

func NewChanges

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

type ChangesByEndpoint

type ChangesByEndpoint map[Endpoint]*Changes

func GroupChanges

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

type Checks []Check

func (Checks) Len

func (checks Checks) Len() int

func (Checks) Less

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

func (Checks) Swap

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

type Endpoint

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

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

func (MarkupFormatter) RenderChangelog

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

func (MarkupFormatter) RenderChecks

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

func (MarkupFormatter) RenderDiff

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

func (MarkupFormatter) RenderFlatten

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

func (MarkupFormatter) RenderSummary

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

func (MarkupFormatter) SupportedOutputs

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

func NewRenderOpts() RenderOpts

type SingleLineFormatter

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

func (SingleLineFormatter) RenderChangelog

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

func (SingleLineFormatter) RenderChecks

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

func (SingleLineFormatter) RenderDiff

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

func (SingleLineFormatter) RenderFlatten

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

func (SingleLineFormatter) RenderSummary

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

func (SingleLineFormatter) SupportedOutputs

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

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