barometer

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 13 Imported by: 3

Documentation

Overview

Package barometer provides the public API for OpenAPI and Arazzo contract testing. It supports both synchronous Run and asynchronous Start returning a Job for IDE/LSP integration. RunWithIndex and StartWithIndex accept a pre-parsed Navigator OpenAPI index for direct Go integration.

Index

Constants

View Source
const (
	FormatHuman       = reporter.FormatHuman
	FormatJUnit       = reporter.FormatJUnit
	FormatJSON        = reporter.FormatJSON
	JSONReportVersion = reporter.JSONReportVersion
)

Variables

View Source
var (
	// ErrConfigRequired indicates that no config was supplied to a run.
	ErrConfigRequired = contract.ErrConfigRequired
	// ErrTargetRequired indicates that no OpenAPI or Arazzo target was supplied.
	ErrTargetRequired = errors.New("at least one OpenAPI spec or Arazzo document is required")
)
View Source
var ReportSchemaJSON string

Functions

func ContractTestRule

func ContractTestRule(baseURL string, opts *RunOpts) barrelman.Rule

ContractTestRule returns a barrelman Rule that runs contract tests against baseURL and reports failures as diagnostics. Can be used standalone with barrelman's engine, or wrapped by editor/CLI integrations.

func WriteOpenAPIReport

func WriteOpenAPIReport(w io.Writer, results []OpenAPIContractResult, format Format, duration time.Duration) error

WriteOpenAPIReport writes OpenAPI-only runtime results in the requested format.

func WriteReport

func WriteReport(w io.Writer, result *Result, format Format, duration time.Duration) error

WriteReport writes a normalized contract report in the requested format.

Types

type ArazzoConfig

type ArazzoConfig = contract.ArazzoConfig

ArazzoConfig configures an Arazzo workflow target.

type ArazzoReport

type ArazzoReport = reporter.ArazzoReport

ArazzoReport is the Arazzo section of the machine-readable report.

type ArazzoResult

type ArazzoResult = contract.ArazzoResult

ArazzoResult contains runtime results for Arazzo workflow execution.

type Client

type Client = runner.Client

Client is the public runtime HTTP client type.

func NewClient

func NewClient(cfg *ClientConfig) (*Client, error)

NewClient returns a public runtime HTTP client.

type ClientConfig

type ClientConfig = runner.Config

ClientConfig configures the public runtime HTTP client.

type Config

type Config = contract.Config

Config is the contract test configuration (same as contract.Config).

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads a config file from disk.

type ContractInput

type ContractInput struct {
	BaseURL         string
	ProxyURL        string
	Output          Format
	OpenAPISpec     string
	OpenAPITags     []string
	ArazzoDoc       string
	ArazzoWorkflows []string
}

ContractInput is the flat integration input shape used by editor and orchestration callers that don't want to hand-build nested config structs.

func (ContractInput) ToConfig

func (in ContractInput) ToConfig() (*Config, error)

ToConfig converts flat integration inputs into the canonical nested config shape.

type Format

type Format = reporter.Format

Format is the public contract report format type.

type JSONReport

type JSONReport = reporter.JSONReport

JSONReport is the versioned machine-readable report shape.

func BuildReport

func BuildReport(result *Result, duration time.Duration) JSONReport

BuildReport returns the normalized JSON report model for a completed run.

type Job

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

Job represents an asynchronous contract test run.

func Start

func Start(ctx context.Context, cfg *Config, client *Client) (*Job, error)

Start starts contract tests in the background. Returns immediately with a Job handle.

func StartInput

func StartInput(ctx context.Context, input ContractInput, client *Client) (*Job, error)

StartInput converts flat integration inputs into config and starts an async run.

func StartWithIndex

func StartWithIndex(ctx context.Context, idx *navigator.Index, baseURL string, opts *RunOpts) *Job

StartWithIndex is the async version of RunWithIndex, returning a Job handle.

func (*Job) Cancel

func (j *Job) Cancel()

Cancel cancels the job's context. The job may not stop immediately.

func (*Job) Done

func (j *Job) Done() <-chan struct{}

Done returns a channel that is closed when the job completes.

func (*Job) Status

func (j *Job) Status() (state string, result *Result, err error)

Status returns the current job state and optional progress.

func (*Job) Wait

func (j *Job) Wait(timeout time.Duration) (*Result, error)

Wait blocks until the job completes, is cancelled, or the timeout elapses.

type OpenAPIConfig

type OpenAPIConfig = contract.OpenAPIConfig

OpenAPIConfig configures an OpenAPI contract-test target.

type OpenAPIContractResult

type OpenAPIContractResult = openapi.ContractResult

OpenAPIContractResult is the per-operation runtime contract result shape.

type OpenAPIReport

type OpenAPIReport = reporter.OpenAPIReport

OpenAPIReport is the OpenAPI section of the machine-readable report.

type OpenAPIResult

type OpenAPIResult = contract.OpenAPIResult

OpenAPIResult contains runtime results for OpenAPI contract tests.

type Result

type Result = contract.Result

Result is the contract test result.

func Run

func Run(ctx context.Context, cfg *Config, client *Client) (*Result, error)

Run runs contract tests synchronously. It blocks until complete or context is cancelled.

func RunInput

func RunInput(ctx context.Context, input ContractInput, client *Client) (*Result, error)

RunInput converts flat integration inputs into config and executes the run.

func RunWithIndex

func RunWithIndex(ctx context.Context, idx *navigator.Index, baseURL string, opts *RunOpts) (*Result, error)

RunWithIndex runs contract tests against a pre-parsed OpenAPI index. This is the primary integration point for editor tooling and similar Go tools.

type RunOpts

type RunOpts struct {
	Client      *Client
	Tags        []string
	OperationID string
	OpenAPISpec string
	ProxyURL    string
	// Credentials maps OpenAPI security scheme names to secret values (API keys, bearer tokens, etc.).
	Credentials map[string]string
}

RunOpts configures RunWithIndex / StartWithIndex (optional client and operation filters).

type WorkflowResult

type WorkflowResult = contract.WorkflowResult

WorkflowResult contains runtime results for an individual Arazzo workflow.

Jump to

Keyboard shortcuts

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