arazzo

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: 15 Imported by: 0

Documentation

Overview

Package arazzo parses and executes Arazzo workflow documents (OpenAPI Initiative).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Components

type Components struct {
	Inputs         map[string]any `yaml:"inputs,omitempty" json:"inputs,omitempty"`
	Parameters     map[string]any `yaml:"parameters,omitempty" json:"parameters,omitempty"`
	SuccessActions map[string]any `yaml:"successActions,omitempty" json:"successActions,omitempty"`
	FailureActions map[string]any `yaml:"failureActions,omitempty" json:"failureActions,omitempty"`
}

Components holds reusable objects.

type Criterion

type Criterion struct {
	Context   string `yaml:"context,omitempty" json:"context,omitempty"` // runtime expression for context
	Condition string `yaml:"condition" json:"condition"`
	Type      string `yaml:"type,omitempty" json:"type,omitempty"` // "simple", "regex", "jsonpath", "xpath"
}

Criterion is a success/failure assertion (simple, regex, jsonpath).

type Doc

type Doc struct {
	Arazzo             string              `yaml:"arazzo" json:"arazzo"`
	Info               Info                `yaml:"info" json:"info"`
	SourceDescriptions []SourceDescription `yaml:"sourceDescriptions" json:"sourceDescriptions"`
	Workflows          []Workflow          `yaml:"workflows" json:"workflows"`
	Components         *Components         `yaml:"components,omitempty" json:"components,omitempty"`
}

Doc is the root Arazzo Description (spec 1.0.x).

func Load

func Load(path string) (*Doc, error)

Load reads an Arazzo document from path (file or URL). URLs are fetched via HTTP.

func (*Doc) RunWorkflow

func (d *Doc) RunWorkflow(ctx context.Context, workflowID, baseURL string, inputs map[string]any, client *runner.Client) (map[string]any, error)

RunWorkflow executes a single workflow with the given inputs and base URL.

func (*Doc) Validate

func (d *Doc) Validate() error

Validate checks required fields and structure.

type Info

type Info struct {
	Title       string `yaml:"title" json:"title"`
	Summary     string `yaml:"summary,omitempty" json:"summary,omitempty"`
	Description string `yaml:"description,omitempty" json:"description,omitempty"`
	Version     string `yaml:"version" json:"version"`
}

Info is metadata about the Arazzo document.

type Parameter

type Parameter struct {
	Name  string `yaml:"name" json:"name"`
	In    string `yaml:"in,omitempty" json:"in,omitempty"`
	Value any    `yaml:"value" json:"value"` // literal or expression string
}

Parameter is a step parameter (query, header, path, cookie).

type RuntimeContext

type RuntimeContext struct {
	Inputs             map[string]any         // workflow inputs
	Steps              map[string]StepOutputs // stepId -> outputs
	Response           *StepResponse          // current step response (statusCode, header, body)
	SourceDescriptions map[string]any         // name -> e.g. { url: "..." }
}

RuntimeContext holds values available during workflow execution ($inputs, $steps, $response, $sourceDescriptions).

func (*RuntimeContext) EvalCriterion

func (c *RuntimeContext) EvalCriterion(crit Criterion) (bool, error)

EvalCriterion evaluates a single criterion (simple, regex, or jsonpath) and returns true if it passes.

func (*RuntimeContext) EvalSimpleCondition

func (c *RuntimeContext) EvalSimpleCondition(condition string) (bool, error)

EvalSimpleCondition evaluates a simple condition like "$statusCode == 200". String comparison is case-insensitive per spec.

func (*RuntimeContext) EvalSuccessCriteria

func (c *RuntimeContext) EvalSuccessCriteria(criteria []Criterion) (bool, error)

EvalSuccessCriteria evaluates all successCriteria; all must pass.

func (*RuntimeContext) Resolve

func (c *RuntimeContext) Resolve(value any) (any, error)

Resolve evaluates an expression (e.g. $inputs.username, $response.body) and returns the value. If value is not a string starting with $, it is returned as-is.

func (*RuntimeContext) ResolveString

func (c *RuntimeContext) ResolveString(value any) (string, error)

ResolveString returns a string value for the expression (for headers, query params).

type SourceDescription

type SourceDescription struct {
	Name string `yaml:"name" json:"name"`
	URL  string `yaml:"url" json:"url"`
	Type string `yaml:"type,omitempty" json:"type,omitempty"` // "openapi" or "arazzo"
}

SourceDescription references an OpenAPI or Arazzo document.

type Step

type Step struct {
	StepID          string         `yaml:"stepId" json:"stepId"`
	Description     string         `yaml:"description,omitempty" json:"description,omitempty"`
	OperationID     string         `yaml:"operationId,omitempty" json:"operationId,omitempty"`
	OperationPath   string         `yaml:"operationPath,omitempty" json:"operationPath,omitempty"`
	WorkflowID      string         `yaml:"workflowId,omitempty" json:"workflowId,omitempty"`
	Parameters      []Parameter    `yaml:"parameters,omitempty" json:"parameters,omitempty"`
	RequestBody     any            `yaml:"requestBody,omitempty" json:"requestBody,omitempty"`
	SuccessCriteria []Criterion    `yaml:"successCriteria,omitempty" json:"successCriteria,omitempty"`
	OnSuccess       []any          `yaml:"onSuccess,omitempty" json:"onSuccess,omitempty"`
	OnFailure       []any          `yaml:"onFailure,omitempty" json:"onFailure,omitempty"`
	Outputs         map[string]any `yaml:"outputs,omitempty" json:"outputs,omitempty"` // map[name]expression
}

Step is a single workflow step (operation or sub-workflow).

type StepOutputs

type StepOutputs map[string]any

StepOutputs is the outputs map for a step.

type StepResponse

type StepResponse struct {
	StatusCode int
	Header     map[string]string
	Body       any // parsed JSON or raw
}

StepResponse is the HTTP response for the current step.

type Workflow

type Workflow struct {
	WorkflowID     string         `yaml:"workflowId" json:"workflowId"`
	Summary        string         `yaml:"summary,omitempty" json:"summary,omitempty"`
	Description    string         `yaml:"description,omitempty" json:"description,omitempty"`
	Inputs         any            `yaml:"inputs,omitempty" json:"inputs,omitempty"` // JSON Schema
	DependsOn      []string       `yaml:"dependsOn,omitempty" json:"dependsOn,omitempty"`
	Steps          []Step         `yaml:"steps" json:"steps"`
	Outputs        map[string]any `yaml:"outputs,omitempty" json:"outputs,omitempty"` // map[name]expression
	Parameters     []Parameter    `yaml:"parameters,omitempty" json:"parameters,omitempty"`
	SuccessActions []any          `yaml:"successActions,omitempty" json:"successActions,omitempty"`
	FailureActions []any          `yaml:"failureActions,omitempty" json:"failureActions,omitempty"`
}

Workflow defines a sequence of steps.

Jump to

Keyboard shortcuts

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