runner

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package runner executes API requests and chains.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertionResult

type AssertionResult struct {
	Expression string
	Passed     bool
	Error      error
}

AssertionResult holds the result of a single assertion

type ChainContext

type ChainContext struct {
	Results map[string]StepResult
}

ChainContext tracks results from chain steps for variable interpolation.

func NewChainContext

func NewChainContext() *ChainContext

NewChainContext creates a new chain context for tracking step results.

func (*ChainContext) AddResult

func (c *ChainContext) AddResult(name string, result *Result)

AddResult stores a step result for later variable interpolation.

func (*ChainContext) ExpandVariables

func (c *ChainContext) ExpandVariables(input string) (string, error)

ExpandVariables replaces $var and ${var} with values from Env or Chain Context.

func (*ChainContext) ResolveVariableRaw

func (c *ChainContext) ResolveVariableRaw(input string) (any, bool)

ResolveVariableRaw checks if input is a pure variable reference (e.g. "$step.field" or "${step.field}") and returns the raw typed value. Returns (value, true) if resolved, (nil, false) otherwise.

type ChainResult

type ChainResult struct {
	Results            []*Result            // Results from each step
	StepNames          []string             // Names of each step
	ExpectationResults []*ExpectationResult // Expectation results from each step
}

ChainResult holds the output of a chain execution

func RunChain

func RunChain(ctx context.Context, factory ExecutorFactory, base *config.ConfigV1, steps []config.ChainStep, opts Options) (*ChainResult, error)

RunChain executes a sequence of steps, merging each step with the base config

type ExecutorFactory

type ExecutorFactory interface {
	Create(transport string) (executor.TransportFunc, error)
}

ExecutorFactory is an interface for creating transport functions

type ExpectationResult

type ExpectationResult struct {
	StatusPassed     bool
	StatusChecked    bool
	AssertionsPassed int
	AssertionsTotal  int
	AssertionResults []AssertionResult
	Error            error
}

ExpectationResult contains the results of running expectations

func CheckExpectations

func CheckExpectations(expect config.Expectation, result *Result) *ExpectationResult

CheckExpectations validates the response against expected values

func (*ExpectationResult) AllPassed

func (e *ExpectationResult) AllPassed() bool

AllPassed returns true if all expectations passed

type Options

type Options struct {
	URLOverride string
	NoColor     bool
}

Options for execution

type Result

type Result struct {
	Body        string
	ContentType string
	StatusCode  int
	Warnings    []string
	RequestURL  string        // The full constructed URL (HTTP/GraphQL only)
	Duration    time.Duration // Time taken for the request
	BodyLines   int
	BodyChars   int
	BodyBytes   int
	Headers     map[string]string // Response headers
}

Result holds the output of a yapi execution

func Run

func Run(ctx context.Context, exec executor.TransportFunc, req *domain.Request, warnings []string, opts Options) (*Result, error)

Run executes a yapi request and returns the result.

type StepResult

type StepResult struct {
	BodyRaw    string
	BodyJSON   map[string]any
	Headers    map[string]string
	StatusCode int
}

StepResult holds the output of a single chain step.

Jump to

Keyboard shortcuts

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