Documentation
¶
Overview ¶
Package expression implements the Arazzo runtime expression parser and evaluator. https://spec.openapis.org/arazzo/v1.0.1#runtime-expressions
Index ¶
- func Evaluate(expr Expression, ctx *Context) (any, error)
- func EvaluateString(input string, ctx *Context) (any, error)
- func UnescapeJSONPointer(s string) string
- func Validate(input string) error
- type ComponentsContext
- type Context
- type Expression
- type ExpressionType
- type SourceDescContext
- type StepContext
- type Token
- type WorkflowContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Evaluate ¶
func Evaluate(expr Expression, ctx *Context) (any, error)
Evaluate resolves a parsed Expression against a Context.
func EvaluateString ¶
EvaluateString parses and evaluates a runtime expression string in one call.
func UnescapeJSONPointer ¶
UnescapeJSONPointer applies RFC 6901 unescaping: ~1 -> /, ~0 -> ~
Types ¶
type ComponentsContext ¶
type ComponentsContext struct {
Parameters map[string]any
SuccessActions map[string]any
FailureActions map[string]any
Inputs map[string]any
}
ComponentsContext holds resolved component data.
type Context ¶
type Context struct {
URL string
Method string
StatusCode int
RequestHeaders map[string]string
RequestQuery map[string]string
RequestPath map[string]string
RequestBody *yaml.Node
ResponseHeaders map[string]string
ResponseBody *yaml.Node
Inputs map[string]any
Outputs map[string]any
Steps map[string]*StepContext
Workflows map[string]*WorkflowContext
SourceDescs map[string]*SourceDescContext
Components *ComponentsContext
}
Context holds runtime values for expression evaluation.
type Expression ¶
type Expression struct {
Type ExpressionType // The kind of expression
Raw string // Original input string
Name string // First segment after prefix (header name, step ID, etc.)
Tail string // Everything after name for Steps/Workflows/SourceDescriptions/Components
Property string // Sub-property for request/response sources (header/query/path name)
JSONPointer string // For body references: the #/path portion
}
Expression represents a parsed Arazzo runtime expression.
func Parse ¶
func Parse(input string) (Expression, error)
Parse parses a single Arazzo runtime expression. Returns a value type to avoid heap allocation.
type ExpressionType ¶
type ExpressionType int
ExpressionType identifies the kind of runtime expression.
const ( URL ExpressionType = iota // $url Method // $method StatusCode // $statusCode RequestHeader // $request.header.{name} RequestQuery // $request.query.{name} RequestPath // $request.path.{name} RequestBody // $request.body{#/json-pointer} ResponseHeader // $response.header.{name} ResponseQuery // $response.query.{name} ResponsePath // $response.path.{name} ResponseBody // $response.body{#/json-pointer} Inputs // $inputs.{name} Outputs // $outputs.{name} Steps // $steps.{name}[.tail] Workflows // $workflows.{name}[.tail] SourceDescriptions // $sourceDescriptions.{name}[.tail] Components // $components.{name}[.tail] ComponentParameters // $components.parameters.{name} )
type SourceDescContext ¶
type SourceDescContext struct {
URL string
}
SourceDescContext holds resolved source description data.
type StepContext ¶
StepContext holds inputs and outputs for a specific step.
type Token ¶
type Token struct {
Literal string // Non-empty if this is a literal text segment
Expression Expression // Valid if IsExpression is true
IsExpression bool // True if this token is an expression
}
Token represents a segment in an embedded expression string like "prefix {$expr} suffix".
func ParseEmbedded ¶
ParseEmbedded parses a string that may contain embedded runtime expressions in {$...} blocks. Returns alternating literal and expression tokens.