arazzo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 27 Imported by: 1

README

Arazzo

Arazzo Parser

An API for working with Arazzo documents including: read, walk, create, mutate, and validate

Release Go Doc
Go Report Card Software License

Read and parse an Arazzo document from a file

Shows loading a document, handling validation errors, and making simple modifications.

ctx := context.Background()

r, err := os.Open("testdata/simple.arazzo.yaml")
if err != nil {
	panic(err)
}
defer r.Close()

a, validationErrs, err := arazzo.Unmarshal(ctx, r)
if err != nil {
	panic(err)
}

for _, err := range validationErrs {
	fmt.Println(err.Error())
}

a.Info.Title = "Updated Simple Workflow"

buf := bytes.NewBuffer([]byte{})

if err := arazzo.Marshal(ctx, a, buf); err != nil {
	panic(err)
}

fmt.Println(buf.String())

Create an Arazzo document from scratch

Shows building a basic workflow document with info and version programmatically.

ctx := context.Background()

a := &arazzo.Arazzo{
	Arazzo: arazzo.Version,
	Info: arazzo.Info{
		Title:   "My Workflow",
		Summary: pointer.From("A summary"),
		Version: "1.0.1",
	},
}

buf := bytes.NewBuffer([]byte{})

err := arazzo.Marshal(ctx, a, buf)
if err != nil {
	panic(err)
}

fmt.Printf("%s", buf.String())

Modify an existing Arazzo document

Shows loading a document, changing properties, and marshaling it back to YAML.

ctx := context.Background()

f, err := os.Open("testdata/simple.arazzo.yaml")
if err != nil {
	panic(err)
}

a, _, err := arazzo.Unmarshal(ctx, f)
if err != nil {
	panic(err)
}

a.Info.Title = "Updated Simple Workflow"

buf := bytes.NewBuffer([]byte{})

if err := arazzo.Marshal(ctx, a, buf); err != nil {
	panic(err)
}

fmt.Printf("%s", buf.String())

Traverse an Arazzo document using the iterator API

Shows how to match different types of objects like workflows during traversal.

ctx := context.Background()

f, err := os.Open("testdata/simple.arazzo.yaml")
if err != nil {
	panic(err)
}

a, _, err := arazzo.Unmarshal(ctx, f)
if err != nil {
	panic(err)
}

for item := range arazzo.Walk(ctx, a) {
	err := item.Match(arazzo.Matcher{
		Workflow: func(workflow *arazzo.Workflow) error {
			fmt.Printf("Workflow: %s\n", workflow.WorkflowID)
			return nil
		},
	})
	if err != nil {
		panic(err)
	}
}

Validate an Arazzo document

Shows loading an invalid document and handling validation errors.

ctx := context.Background()

f, err := os.Open("testdata/invalid.arazzo.yaml")
if err != nil {
	panic(err)
}

_, validationErrs, err := arazzo.Unmarshal(ctx, f)
if err != nil {
	panic(err)
}

for _, err := range validationErrs {
	fmt.Printf("%s\n", err.Error())
}

Contributing

This repository is maintained by Speakeasy, but we welcome and encourage contributions from the community to help improve its capabilities and stability.

How to Contribute

  1. Open Issues: Found a bug or have a feature suggestion? Open an issue to describe what you'd like to see changed.

  2. Pull Requests: We welcome pull requests! If you'd like to contribute code:

    • Fork the repository
    • Create a new branch for your feature/fix
    • Submit a PR with a clear description of the changes and any related issues
  3. Feedback: Share your experience using the packages or suggest improvements.

All contributions, whether they're bug reports, feature requests, or code changes, help make this project better for everyone.

Please ensure your contributions adhere to our coding standards and include appropriate tests where applicable.

Documentation

Overview

Package arazzo provides an API for working with Arazzo documents including reading, creating, mutating, walking and validating them.

The Arazzo Specification is a mechanism for orchestrating API calls, defining their sequences and dependencies, to achieve specific outcomes when working with API descriptions like OpenAPI.

Example (Creating)

Example_creating demonstrates how to create an Arazzo document from scratch. Shows building a basic workflow document with info and version programmatically.

package main

import (
	"bytes"
	"context"
	"fmt"

	"github.com/speakeasy-api/openapi/arazzo"
	"github.com/speakeasy-api/openapi/pointer"
)

func main() {
	ctx := context.Background()

	a := &arazzo.Arazzo{
		Arazzo: arazzo.Version,
		Info: arazzo.Info{
			Title:   "My Workflow",
			Summary: pointer.From("A summary"),
			Version: "1.0.1",
		},
		// ...
	}

	buf := bytes.NewBuffer([]byte{})

	err := arazzo.Marshal(ctx, a, buf)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%s", buf.String())
}
Output:

arazzo: 1.0.1
info:
  title: My Workflow
  summary: A summary
  version: 1.0.1
Example (Mutating)

Example_mutating demonstrates how to modify an existing Arazzo document. Shows loading a document, changing properties, and marshaling it back to YAML.

package main

import (
	"bytes"
	"context"
	"fmt"
	"os"

	"github.com/speakeasy-api/openapi/arazzo"
)

func main() {
	ctx := context.Background()

	f, err := os.Open("testdata/simple.arazzo.yaml")
	if err != nil {
		panic(err)
	}

	a, _, err := arazzo.Unmarshal(ctx, f)
	if err != nil {
		panic(err)
	}

	a.Info.Title = "Updated Simple Workflow"

	buf := bytes.NewBuffer([]byte{})

	if err := arazzo.Marshal(ctx, a, buf); err != nil {
		panic(err)
	}

	fmt.Printf("%s", buf.String())
}
Output:

arazzo: 1.0.0
info:
  title: Updated Simple Workflow
  version: 1.0.0
sourceDescriptions:
  - name: api
    url: https://api.example.com/openapi.yaml
    type: openapi
workflows:
  - workflowId: simpleWorkflow
    summary: A simple workflow
    steps:
      - stepId: step1
        operationId: getUser
        parameters:
          - name: id
            in: path
            value: "123"
Example (Reading)

Example_reading demonstrates how to read and parse an Arazzo document from a file. Shows loading a document, handling validation errors, and making simple modifications.

package main

import (
	"bytes"
	"context"
	"fmt"
	"os"

	"github.com/speakeasy-api/openapi/arazzo"
)

func main() {
	ctx := context.Background()

	r, err := os.Open("testdata/simple.arazzo.yaml")
	if err != nil {
		panic(err)
	}
	defer r.Close()

	// Unmarshal the Arazzo document which will also validate it against the Arazzo Specification
	a, validationErrs, err := arazzo.Unmarshal(ctx, r)
	if err != nil {
		panic(err)
	}

	// Validation errors are returned separately from any errors that block the document from being unmarshalled
	// allowing an invalid document to be mutated and fixed before being marshalled again
	for _, err := range validationErrs {
		fmt.Println(err.Error())
	}

	// Mutate the document by just modifying the returned Arazzo object
	a.Info.Title = "Updated Simple Workflow"

	buf := bytes.NewBuffer([]byte{})

	// Marshal the document to a writer
	if err := arazzo.Marshal(ctx, a, buf); err != nil {
		panic(err)
	}

	fmt.Println(buf.String())
}
Output:

arazzo: 1.0.0
info:
  title: Updated Simple Workflow
  version: 1.0.0
sourceDescriptions:
  - name: api
    url: https://api.example.com/openapi.yaml
    type: openapi
workflows:
  - workflowId: simpleWorkflow
    summary: A simple workflow
    steps:
      - stepId: step1
        operationId: getUser
        parameters:
          - name: id
            in: path
            value: "123"
Example (Validating)

Example_validating demonstrates how to validate an Arazzo document. Shows loading an invalid document and handling validation errors.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/speakeasy-api/openapi/arazzo"
)

func main() {
	ctx := context.Background()

	f, err := os.Open("testdata/invalid.arazzo.yaml")
	if err != nil {
		panic(err)
	}

	_, validationErrs, err := arazzo.Unmarshal(ctx, f)
	if err != nil {
		panic(err)
	}

	for _, err := range validationErrs {
		fmt.Printf("%s\n", err.Error())
	}
}
Output:

[3:3] info field version is missing
[13:9] step at least one of operationId, operationPath or workflowId fields must be set
Example (Walking)

Example_walking demonstrates how to traverse an Arazzo document using the iterator API. Shows how to match different types of objects like workflows during traversal.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/speakeasy-api/openapi/arazzo"
)

func main() {
	ctx := context.Background()

	f, err := os.Open("testdata/simple.arazzo.yaml")
	if err != nil {
		panic(err)
	}

	a, _, err := arazzo.Unmarshal(ctx, f)
	if err != nil {
		panic(err)
	}

	for item := range arazzo.Walk(ctx, a) {
		err := item.Match(arazzo.Matcher{
			Workflow: func(workflow *arazzo.Workflow) error {
				fmt.Printf("Workflow: %s\n", workflow.WorkflowID)
				return nil
			},
		})
		if err != nil {
			panic(err)
		}
	}
}
Output:

Workflow: simpleWorkflow

Index

Examples

Constants

View Source
const (
	Version      = "1.0.1"
	VersionMajor = 1
	VersionMinor = 0
	VersionPatch = 1
)

Version is the version of the Arazzo Specification that this package conforms to.

View Source
const (
	// SourceDescriptionTypeOpenAPI represents a SourceDescription that describes an OpenAPI document.
	SourceDescriptionTypeOpenAPI = "openapi"
	// SourceDescriptionTypeArazzo represents a SourceDescription that describes an Arazzo document.
	SourceDescriptionTypeArazzo = "arazzo"
)

Variables

This section is empty.

Functions

func Marshal

func Marshal(ctx context.Context, arazzo *Arazzo, w io.Writer) error

Marshal will marshal the provided Arazzo document to the provided io.Writer.

func Walk

func Walk(ctx context.Context, arazzo *Arazzo) iter.Seq[WalkItem]

Walk returns an iterator that yields MatchFunc items for each model in the Arazzo document. Users can iterate over the results using a for loop and break out at any time.

Types

type Arazzo

type Arazzo struct {
	marshaller.Model[core.Arazzo]

	// Arazzo is the version of the Arazzo Specification that this document conforms to.
	Arazzo string
	// Info provides metadata about the Arazzo document.
	Info Info
	// SourceDescriptions provides a list of SourceDescription objects that describe the source of the data that the workflow is orchestrating.
	SourceDescriptions SourceDescriptions
	// Workflows provides a list of Workflow objects that describe the orchestration of API calls.
	Workflows Workflows
	// Components provides a list of reusable components that can be used in the workflow.
	Components *Components
	// Extensions provides a list of extensions to the Arazzo document.
	Extensions *extensions.Extensions
}

Arazzo is the root object for an Arazzo document.

func Unmarshal

func Unmarshal(ctx context.Context, doc io.Reader, opts ...Option[unmarshalOptions]) (*Arazzo, []error, error)

Unmarshal will unmarshal and validate an Arazzo document from the provided io.Reader. Validation can be skipped by using arazzo.WithSkipValidation() as one of the options when calling this function.

func (*Arazzo) Sync added in v0.1.1

func (a *Arazzo) Sync(ctx context.Context) error

Sync will sync any changes made to the Arazzo document models back to the core models.

func (*Arazzo) Validate

func (a *Arazzo) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the Arazzo document against the Arazzo Specification.

type Components

type Components struct {
	marshaller.Model[core.Components]

	// Inputs provides a list of reusable JSON Schemas that can be referenced from inputs and other JSON Schemas.
	Inputs *sequencedmap.Map[string, *oas3.JSONSchema[oas3.Referenceable]]
	// Parameters provides a list of reusable parameters that can be referenced from workflows and steps.
	Parameters *sequencedmap.Map[string, *Parameter]
	// SuccessActions provides a list of reusable success actions that can be referenced from workflows and steps.
	SuccessActions *sequencedmap.Map[string, *SuccessAction]
	// FailureActions provides a list of reusable failure actions that can be referenced from workflows and steps.
	FailureActions *sequencedmap.Map[string, *FailureAction]
	// Extensions provides a list of extensions to the Components object.
	Extensions *extensions.Extensions
}

Components holds reusable components that can be referenced in an Arazzo document.

func (*Components) Validate

func (c *Components) Validate(ctx context.Context, opts ...validation.Option) []error

Validate validates the Components object.

type FailureAction

type FailureAction struct {
	marshaller.Model[core.FailureAction]

	// Name is the case-sensitive name of the failure action.
	Name string
	// Type is the type of action to take on failure.
	Type FailureActionType
	// WorkflowID is the workflow ID of the workflow/step to go to on failure. Mutually exclusive to StepID.
	WorkflowID *expression.Expression
	// StepID is the step ID of the workflow/step to go to on failure. Mutually exclusive to WorkflowID.
	StepID *string
	// RetryAfter is the number of seconds to wait before retrying the workflow/step on failure.
	RetryAfter *float64
	// RetryLimit is the number of times to retry the workflow/step on failure. If not set a single retry will be attempted if type is retry.
	RetryLimit *int
	// A list of assertions to check before taking the action.
	Criteria []criterion.Criterion
	// Extensions provides a list of extensions to the FailureAction object.
	Extensions *extensions.Extensions
}

FailureAction represents an action to take on failure of a workflow/step.

func (*FailureAction) Validate

func (f *FailureAction) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the failure action object. Requires an Arazzo object to be passed via validation options with validation.WithContextObject(). If a Workflow object is provided via validation options with validation.WithContextObject() then the FailureAction will be validated with the context of the workflow.

type FailureActionType

type FailureActionType string

FailureActionType represents the type of action to take on failure.

const (
	// FailureActionTypeEnd indicates that the workflow/step should end.
	FailureActionTypeEnd FailureActionType = "end"
	// FailureActionTypeGoto indicates that the workflow/step should go to another workflow/step on failure.
	FailureActionTypeGoto FailureActionType = "goto"
	// FailureActionTypeRetry indicates that the workflow/step should retry on failure.
	FailureActionTypeRetry FailureActionType = "retry"
)

type In

type In string

In represents the location of a parameter.

const (
	// InPath indicates that the parameter is in the path of the request.
	InPath In = "path"
	// InQuery indicates that the parameter is in the query of the request.
	InQuery In = "query"
	// InHeader indicates that the parameter is in the header of the request.
	InHeader In = "header"
	// InCookie indicates that the parameter is in the cookie of the request.
	InCookie In = "cookie"
)

type Info

type Info struct {
	marshaller.Model[core.Info]

	// Title is the name of the Arazzo document
	Title string
	// Summary is a short description of the Arazzo document
	Summary *string
	// Description is a longer description of the Arazzo document. May contain CommonMark syntax.
	Description *string
	// Version is the version of the Arazzo document
	Version string
	// Extensions provides a list of extensions to the Info object.
	Extensions *extensions.Extensions
}

Info represents metadata about the Arazzo document

func (*Info) Validate

func (i *Info) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the Info object against the Arazzo Specification.

type LocationContext added in v1.0.0

type LocationContext = walkpkg.LocationContext[MatchFunc]

Use the shared walking infrastructure

type Locations added in v1.0.0

type Locations = walkpkg.Locations[MatchFunc]

type MatchFunc

type MatchFunc func(Matcher) error

MatchFunc represents a particular model in the Arazzo document that can be matched. Pass it a Matcher with the appropriate functions populated to match the model type(s) you are interested in.

type Matcher

type Matcher struct {
	Arazzo                func(*Arazzo) error
	Info                  func(*Info) error
	SourceDescription     func(*SourceDescription) error
	Workflow              func(*Workflow) error
	ReusableParameter     func(*ReusableParameter) error
	JSONSchema            func(*oas3.JSONSchema[oas3.Referenceable]) error
	Step                  func(*Step) error
	ReusableSuccessAction func(*ReusableSuccessAction) error
	ReusableFailureAction func(*ReusableFailureAction) error
	Components            func(*Components) error
	Parameter             func(*Parameter) error
	SuccessAction         func(*SuccessAction) error
	FailureAction         func(*FailureAction) error
	Extensions            func(*extensions.Extensions) error
	Any                   func(any) error // Any will be called along with the other functions above on a match of a model
}

Matcher is a struct that can be used to match specific nodes in the Arazzo document.

type Option

type Option[T any] func(o *T)

func WithSkipValidation

func WithSkipValidation() Option[unmarshalOptions]

WithSkipValidation will skip validation of the Arazzo document during unmarshaling. Useful to quickly load a document that will be mutated and validated later.

type Outputs

Outputs is a map of friendly name to expressions that extract data from the workflows/steps.

type Parameter

type Parameter struct {
	marshaller.Model[core.Parameter]

	// Name is the case-sensitive name of the parameter.
	Name string
	// In is the location of the parameter within an operation.
	In *In
	// Value represents either the static value of the parameter or an expression that will be evaluated to produce the value.
	Value expression.ValueOrExpression
	// Extensions provides a list of extensions to the Parameter object.
	Extensions *extensions.Extensions
}

Parameter represents parameters that will be passed to a workflow or operation referenced by a step.

func (*Parameter) Validate

func (p *Parameter) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the parameter object against the Arazzo specification. If an Workflow or Step object is provided via validation options with validation.WithContextObject() then it will be validated in the context of that object.

type PayloadReplacement

type PayloadReplacement struct {
	marshaller.Model[core.PayloadReplacement]

	// Target is a JSON pointer of XPath expression to the value to be replaced.
	Target jsonpointer.JSONPointer // TODO also support XPath
	// Value represents either the static value of the replacem	ent or an expression that will be evaluated to produce the value.
	Value expression.ValueOrExpression
	// Extensions provides a list of extensions to the PayloadReplacement object.
	Extensions *extensions.Extensions
}

PayloadReplacement represents a replacement of a value within a payload such as a request body.

func (*PayloadReplacement) Validate

func (p *PayloadReplacement) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the payload replacement object against the Arazzo specification.

type RequestBody

type RequestBody struct {
	marshaller.Model[core.RequestBody]

	// ContentType is the content type of the request body
	ContentType *string
	// Payload is a static value, an expression or a value containing inline expressions that will be used to populate the request body
	Payload expression.ValueOrExpression
	// Replacements is a list of expressions that will be used to populate the request body in addition to any in the Payload field
	Replacements []*PayloadReplacement
	// Extensions is a list of extensions to apply to the request body object
	Extensions *extensions.Extensions
}

RequestBody represents the request body to pass to an operation represented by a step

func (*RequestBody) Validate

func (r *RequestBody) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the request body object against the Arazzo specification.

type Reusable

type Reusable[T any, V interfaces.Validator[T], C marshaller.CoreModeler] struct {
	marshaller.Model[core.Reusable[C]]

	// Reference is the expression to the location of the reusable object.
	Reference *expression.Expression
	// Value is any value provided alongside a parameter reusable object.
	Value values.Value
	// If this reusable object is not a reference, this will be the inline object for this node.
	Object V
}

func (*Reusable[T, V, C]) Get added in v0.1.0

func (r *Reusable[T, V, C]) Get(components *Components) *T

Get will return either the inline object or the object referenced by the reference.

func (*Reusable[T, V, C]) GetReferencedObject added in v0.1.0

func (r *Reusable[T, V, C]) GetReferencedObject(components *Components) *T

func (*Reusable[T, V, C]) IsReference added in v0.1.0

func (r *Reusable[T, V, C]) IsReference() bool

func (*Reusable[T, V, C]) Validate

func (r *Reusable[T, V, C]) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the reusable object against the Arazzo specification.

type ReusableFailureAction

type ReusableFailureAction = Reusable[FailureAction, *FailureAction, *core.FailureAction]

ReusableFailureAction represents a failure action that can either be referenced from components or declared inline in a workflow or step.

type ReusableParameter

type ReusableParameter = Reusable[Parameter, *Parameter, *core.Parameter]

ReusableParameter represents a parameter that can either be referenced from components or declared inline in a workflow or step.

type ReusableSuccessAction

type ReusableSuccessAction = Reusable[SuccessAction, *SuccessAction, *core.SuccessAction]

ReusableSuccessAction represents a success action that can either be referenced from components or declared inline in a workflow or step.

type SourceDescription

type SourceDescription struct {
	marshaller.Model[core.SourceDescription]

	// Name is the case-sensitive name of the SourceDescription object used to reference it.
	Name string
	// URL is a URL or relative URI to the location of the referenced document.
	URL string
	// Type is the type of the referenced document.
	Type SourceDescriptionType
	// Extensions provides a list of extensions to the SourceDescription object.
	Extensions *extensions.Extensions
}

SourceDescription represents an Arazzo or OpenAPI document that is referenced by this Arazzo document.

func (*SourceDescription) Validate

func (s *SourceDescription) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the source description object against the Arazzo specification.

type SourceDescriptionType

type SourceDescriptionType string

SourceDescriptionType represents the type of the SourceDescription object.

type SourceDescriptions

type SourceDescriptions []*SourceDescription

SourceDescriptions represents a list of SourceDescription objects that describe the source of the data that the workflow is orchestrating.

func (SourceDescriptions) Find

Find will return the first SourceDescription object with the provided name.

type Step

type Step struct {
	marshaller.Model[core.Step]

	// StepID is a unique identifier for the step within a workflow.
	StepID string
	// Description is a description of the step.
	Description *string
	// OperationID is an operationId or expression to an operation in a SourceDescription that the step relates to. Mutually exclusive with OperationPath & WorkflowID.
	OperationID *expression.Expression
	// OperationPath is an expression to an operation in a SourceDescription that the step relates to. Mutually exclusive with OperationID & WorkflowID.
	OperationPath *expression.Expression
	// WorkflowID is a workflowId or expression to a workflow in a SourceDescription that the step relates to. Mutually exclusive with OperationID & OperationPath.
	WorkflowID *expression.Expression
	// Parameters is a list of Parameters that will be passed to the referenced operation or workflow. These will override any matching parameters defined at the workflow level.
	Parameters []*ReusableParameter
	// RequestBody is the request body to be passed to the referenced operation.
	RequestBody *RequestBody
	// SuccessCriteria is a list of criteria that must be met for the step to be considered successful.
	SuccessCriteria []*criterion.Criterion
	// OnSuccess is a list of SuccessActions that will be executed if the step is successful.
	OnSuccess []*ReusableSuccessAction
	// OnFailure is a list of FailureActions that will be executed if the step is unsuccessful.
	OnFailure []*ReusableFailureAction
	// Outputs is a list of outputs that will be returned by the step.
	Outputs Outputs
	// Extensions provides a list of extensions to the Step object.
	Extensions *extensions.Extensions
}

Step represents a step in a workflow that describes the operation to be performed.

func (*Step) Validate

func (s *Step) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the step object against the Arazzo specification. Requires an Arazzo object to be passed via validation options with validation.WithContextObject(). Requires a Workflow object to be passed via validation options with validation.WithContextObject().

type Steps

type Steps []*Step

Steps represents a list of Step objects that describe the operations to be performed in the workflow.

func (Steps) Find

func (s Steps) Find(id string) *Step

Find will return the first Step object with the provided id.

type SuccessAction

type SuccessAction struct {
	marshaller.Model[core.SuccessAction]

	// Name is a case-sensitive name for the SuccessAction.
	Name string
	// Type is the type of action to take on success.
	Type SuccessActionType
	// WorkflowID is the workflow/step to go to on success. Mutually exclusive to StepID.
	WorkflowID *expression.Expression
	// StepID is the workflow/step to go to on success. Mutually exclusive to WorkflowID.
	StepID *string
	// Criteria is a list of criteria that must be met for the action to be taken.
	Criteria []criterion.Criterion
	// Extensions provides a list of extensions to the SuccessAction object.
	Extensions *extensions.Extensions
}

SuccessAction represents an action to take on success of a workflow/step.

func (*SuccessAction) Validate

func (s *SuccessAction) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the success action object against the Arazzo specification. Requires an Arazzo object to be passed via validation options with validation.WithContextObject().

type SuccessActionType

type SuccessActionType string

SuccessActionType represents the type of action to take on success.

const (
	// SuccessActionTypeEnd indicates that the workflow/step should end.
	SuccessActionTypeEnd SuccessActionType = "end"
	// SuccessActionTypeGoto indicates that the workflow/step should go to another workflow/step on success.
	SuccessActionTypeGoto SuccessActionType = "goto"
)

type WalkItem added in v1.0.0

type WalkItem struct {
	Match    MatchFunc
	Location Locations
	Arazzo   *Arazzo
}

WalkItem represents a single item yielded by the Walk iterator.

type Workflow

type Workflow struct {
	marshaller.Model[core.Workflow]

	// WorkflowID is a unique identifier for the workflow.
	WorkflowID string
	// Summary is a short description of the purpose of the workflow.
	Summary *string
	// Description is a longer description of the purpose of the workflow. May contain CommonMark syntax.
	Description *string
	// Parameters is a list of Parameters that will be passed to the referenced operation or workflow.
	Parameters []*ReusableParameter
	// Inputs is a JSON Schema containing a set of inputs that will be passed to the referenced workflow.
	Inputs *oas3.JSONSchema[oas3.Referenceable]
	// DependsOn is a list of workflowIds (or expressions to workflows) that must succeed before this workflow can be executed.
	DependsOn []expression.Expression
	// Steps is a list of steps that will be executed in the order they are listed.
	Steps Steps
	// SuccessActions is a list of actions that will be executed by each step in the workflow if the step succeeds. Can be overridden by the step.
	SuccessActions []*ReusableSuccessAction
	// FailureActions is a list of actions that will be executed by each step in the workflow if the step fails. Can be overridden by the step.
	FailureActions []*ReusableFailureAction
	// Outputs is a set of outputs that will be returned by the workflow.
	Outputs Outputs
	// Extensions provides a list of extensions to the Workflow object.
	Extensions *extensions.Extensions
}

Workflow represents a set of steps that orchestrates the execution of API calls.

func (*Workflow) Validate

func (w *Workflow) Validate(ctx context.Context, opts ...validation.Option) []error

Validate will validate the workflow object against the Arazzo specification. Requires an Arazzo object to be passed via validation options with validation.WithContextObject().

type Workflows

type Workflows []*Workflow

Workflows provides a list of Workflow objects that describe the orchestration of API calls.

func (Workflows) Find

func (w Workflows) Find(id string) *Workflow

Find will return the first workflow with the matching workflowId.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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