contract

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package contract defines the lint and compare plugin input/output types matching the published JSON Schema contracts at https://ifc7.dev/schemas/plugins/v0/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompareInput

type CompareInput struct {
	InterfaceType InterfaceType         `json:"interfaceType"`
	Before        SpecificationDocument `json:"before"`
	After         SpecificationDocument `json:"after"`
	Options       map[string]any        `json:"options,omitempty"`
}

CompareInput is the input contract for change-detector plugins.

type CompareOutput

type CompareOutput struct {
	Breaking bool           `json:"breaking"`
	Raw      string         `json:"raw"`
	Extra    map[string]any `json:"extra,omitempty"`
}

CompareOutput is the output contract for change-detector plugins.

type FileFormat

type FileFormat string

FileFormat is the serialization format of decoded specification bytes.

const (
	FileFormatJSON FileFormat = "json"
	FileFormatYAML FileFormat = "yaml"
)

func DetectFileFormat

func DetectFileFormat(raw []byte) FileFormat

DetectFileFormat returns json or yaml based on content.

type InterfaceType

type InterfaceType string

InterfaceType identifies the kind of interface specification.

const (
	InterfaceTypeOpenAPI    InterfaceType = "OPENAPI"
	InterfaceTypeJSONSchema InterfaceType = "JSON_SCHEMA"
)

type LintInput

type LintInput struct {
	InterfaceType InterfaceType         `json:"interfaceType"`
	Document      SpecificationDocument `json:"document"`
	Options       map[string]any        `json:"options,omitempty"`
}

LintInput is the input contract for linter plugins.

type LintOutput

type LintOutput struct {
	Score int            `json:"score"`
	Raw   string         `json:"raw"`
	Extra map[string]any `json:"extra,omitempty"`
}

LintOutput is the output contract for linter plugins.

type SpecificationDocument

type SpecificationDocument struct {
	Specification string     `json:"specification"`
	FileFormat    FileFormat `json:"fileFormat"`
}

SpecificationDocument is a single interface specification payload.

func NewSpecificationDocument

func NewSpecificationDocument(raw []byte, format FileFormat) SpecificationDocument

NewSpecificationDocument encodes raw bytes as a SpecificationDocument.

func (SpecificationDocument) Decode

func (d SpecificationDocument) Decode() ([]byte, error)

Decode returns the raw specification bytes.

Jump to

Keyboard shortcuts

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