OpenAPI Hub
Arazzo in OpenAPI best practices
Arazzo: OpenAPI Workflows
The Arazzo Specification is a new addition to the OpenAPI Specification that allows you to define sequences of operations for your API.
An Arazzo description is a separate document that references your OpenAPI document and describes how to combine operations from your OpenAPI document into step-by-step sequences.
Arazzo descriptions are useful for:
- Defining complex sequences of operations that involve multiple API calls.
- Documenting the expected behavior of your API in a more structured way than a narrative description.
- Generating code to execute the sequences of operations.
- Generating tests to verify that the sequences of operations behave as expected.
- Generating documentation that explains how to use the sequences of operations.
Arazzo Description Structure
An Arazzo description is a JSON or YAML document that follows the structure defined by the Arazzo Specification.
Arazzo version
| Field Name | Type | Required |
|---|---|---|
arazzo | string | ✅ |
The version of the Arazzo Specification that the document uses. The value must be a supported version number.
workflowsSpec: 1.0.0-prereleaseInfo metadata
| Field Name | Type | Required |
|---|---|---|
info | Info Object | ✅ |
Provides metadata about the Arazzo description.
info: title: Speakeasy Bar Workflows summary: Workflows for managing the Speakeasy Bar API description: > This document defines workflows for managing the [Speakeasy Bar API](https://bar.example.com), including creating new drinks, managing inventory, and processing orders. version: 4.6.3Source description
| Field Name | Type | Required |
|---|---|---|
sourceDescriptions | [Source Description Object] | ✅ |
An array of source description objects defining the OpenAPI or other documents containing the operations referenced by the workflows. The array must contain at least one source.
sourceDescriptions: - name: speakeasyBar url: https://bar.example.com/openapi.yaml type: openapi - name: printsAndBeeps url: https://output.example.com/workflows.yaml type: workflowsSpecWorkflows
| Field Name | Type | Required |
|---|---|---|
workflows | [Workflow Object] | ✅ |
An array of workflow objects defining the workflows. The array must contain at least one workflow.
workflows: - workflowId: createDrink summary: Create a new drink in the bar's menu inputs: allOf: - $ref: "#/components/inputs/authenticate" - type: object properties: drink_name: type: string drink_type: type: string drink_price_usd_cent: type: integer ingredients: type: array items: type: string steps: - stepId: authenticate operationId: authenticate parameters: - reference: $components.parameters.username - reference: $components.parameters.password - stepId: createDrink operationId: createDrink parameters: - reference: $components.parameters.authorization - name: name in: query value: $inputs.drink_name - name: type in: query value: $inputs.drink_type - name: price in: query value: $inputs.drink_price_usd_cent - name: ingredients in: query value: $inputs.ingredients - workflowId: makeDrink summary: Order a drink and check the order status inputs: - name: orderType description: The type of order type: string required: true - name: productCode description: The product code of the drink type: string required: true - name: quantity description: The quantity of the drink type: integer required: true steps: - stepId: orderDrink operationId: createOrder parameters: - name: orderType in: body value: $inputs.orderType - name: productCode in: body value: $inputs.productCode - name: quantity in: body value: $inputs.quantity - stepId: checkStatus operationId: getOrder parameters: - name: orderNumber in: path value: $orderDrink.orderNumber successCriteria: - type: simple condition: $checkStatus.status == 'completed' onSuccess: - name: printReceipt type: goto workflowId: $sourceDescriptions.printsAndBeeps.printReceipt criteria: - type: simple condition: $checkStatus.status == 'completed' onFailure: - name: beepLoudly type: goto workflowId: $sourceDescriptions.printsAndBeeps.beepLoudly criteria: - type: simple condition: $checkStatus.status == 'failed' - workflowId: addIngredient summary: Add a new ingredient to the bar's inventory inputs: - name: username description: The username of the manager type: string required: true - name: password description: The password of the manager type: string required: true - name: ingredient_name description: The name of the ingredient type: string required: true - name: ingredient_type description: The type of the ingredient type: string required: true - name: ingredient_stock description: The stock of the ingredient type: integer required: true - name: productCode description: The product code of the ingredient type: string required: true steps: - stepId: authenticate operationId: authenticate parameters: - reference: $components.parameters.username value: admin - reference: $components.parameters.password - stepId: addIngredient operationId: createIngredient parameters: - reference: $components.parameters.authorization - name: name in: query value: $inputs.ingredient_name - name: type in: query value: $inputs.ingredient_type - name: stock in: query value: $inputs.ingredient_stock - name: productCode in: query value: $inputs.productCodecomponents: inputs: authenticate: type: object properties: username: type: string password: type: string parameters: authorization: name: Authorization in: header value: $authenticate.outputs.token username: name: username in: body value: $inputs.username password: name: password in: body value: $inputs.passwordThis table shows all fields at the root of the Arazzo Specification:
arazzostringinfosourceDescriptionsworkflowscomponentsx-*Arazzo Specification Versions
The arazzo field contains the version number of the Arazzo Specification that the document conforms to. Tooling should use this value to interpret the document correctly.
The current version of the Arazzo Specification is 1.0.0-prerelease, but keep in mind that the specification is still under development.
Info Object
Provides metadata about the Arazzo description.
titlestringsummarystringdescriptionstringversionstringx-*Below is an example of an info object in an Arazzo document:
info: title: Speakeasy Bar Workflows summary: Workflows for managing the Speakeasy Bar API description: > This document defines workflows for managing the [Speakeasy Bar API](https://bar.example.com), including creating new drinks, managing inventory, and processing orders. version: 4.6.3Source Description Object
A source description points to an OpenAPI document containing the operations referenced by the workflows in this document. It may also reference other Arazzo documents.
namestringsourceDescriptions array and may only contain alphanumeric characters, underscores, and dashes.urlstringtypestringopenapi, indicating an OpenAPI document, or arazzo indicating another Arazzo description. Additional values may be supported in future versions of the specification.x-*Below is an example of two source description objects in an Arazzo description document:
sourceDescriptions: - name: speakeasyBar url: https://bar.example.com/openapi.yaml type: openapi - name: printsAndBeeps url: https://output.example.com/workflows.yaml type: workflowsSpecWorkflow Object
A workflow object defines a sequence of operations.
workflowIdstringsummarystringdescriptionstringinputsdependsOnstring]stepssuccessActionsfailureActionsoutputsstring, {Runtime Expression}]parametersx-*Below is an example of a workflow object:
workflows: - workflowId: createDrink summary: Create a new drink in the bar's menu inputs: allOf: - $ref: "#/components/inputs/authenticate" - type: object properties: drink_name: type: string drink_type: type: string drink_price_usd_cent: type: integer ingredients: type: array items: type: string steps: - stepId: authenticate operationId: authenticate parameters: - reference: $components.parameters.username - reference: $components.parameters.password - stepId: createDrink operationId: createDrink parameters: - reference: $components.parameters.authorization - name: name in: query value: $inputs.drink_name - name: type in: query value: $inputs.drink_type - name: price in: query value: $inputs.drink_price_usd_cent - name: ingredients in: query value: $inputs.ingredients - workflowId: makeDrink summary: Order a drink and check the order status inputs: - name: orderType description: The type of order type: string required: true - name: productCode description: The product code of the drink type: string required: true - name: quantity description: The quantity of the drink type: integer required: true steps: - stepId: orderDrink operationId: createOrder parameters: - name: orderType in: body value: $inputs.orderType - name: productCode in: body value: $inputs.productCode - name: quantity in: body value: $inputs.quantity - stepId: checkStatus operationId: getOrder parameters: - name: orderNumber in: path value: $orderDrink.orderNumber successCriteria: - type: simple condition: $checkStatus.status == 'completed' onSuccess: - name: printReceipt type: goto workflowId: $sourceDescriptions.printsAndBeeps.printReceipt criteria: - type: simple condition: $checkStatus.status == 'completed' onFailure: - name: beepLoudly type: goto workflowId: $sourceDescriptions.printsAndBeeps.beepLoudly criteria: - type: simple condition: $checkStatus.status == 'failed' - workflowId: addIngredient summary: Add a new ingredient to the bar's inventory inputs: - name: username description: The username of the manager type: string required: true - name: password description: The password of the manager type: string required: true - name: ingredient_name description: The name of the ingredient type: string required: true - name: ingredient_type description: The type of the ingredient type: string required: true - name: ingredient_stock description: The stock of the ingredient type: integer required: true - name: productCode description: The product code of the ingredient type: string required: true steps: - stepId: authenticate operationId: authenticate parameters: - reference: $components.parameters.username value: admin - reference: $components.parameters.password - stepId: addIngredient operationId: createIngredient parameters: - reference: $components.parameters.authorization - name: name in: query value: $inputs.ingredient_name - name: type in: query value: $inputs.ingredient_type - name: stock in: query value: $inputs.ingredient_stock - name: productCode in: query value: $inputs.productCodeStep Object
A step object defines a single operation to perform as part of a workflow.
stepIdstringdescriptionstringoperationIdstringoperationId of the operation to execute for this step. Must match an operationId in one of the sourceDescriptions. This field is mutually exclusive with operationPath and workflowId.operationPathstringsourceDescriptions. This field is mutually exclusive with operationId and workflowId.workflowIdstringoperationId and operationPath.parametersrequestBodysuccessCriteriaonSuccessonFailureoutputsstring, {Runtime Expression}]x-*Below is an example of step objects in an Arazzo description document:
steps: - stepId: orderDrink operationId: createOrder parameters: - name: orderType in: body value: $inputs.orderType - name: productCode in: body value: $inputs.productCode - name: quantity in: body value: $inputs.quantityParameter Object
A parameter object defines a single parameter to pass to an operation in a workflow step.
namestringinstringpath, query, header, cookie. Required for parameters passed to an operation. Must be omitted for parameters passed to a workflow, where the parameter is always passed in the workflow's inputs object. See Parameter Location.valuex-*Parameter Location
For parameters passed to an operation, the in field specifies the location of the parameter. The possible values are:
path- The parameter is part of the operation’s URL path.query- The parameter is appended to the operation’s URL as a query parameter.header- The parameter is sent in the request headers.cookie- The parameter is sent in a cookie.
For parameters passed to a workflow, the in field must be omitted. Workflow parameters are always passed in the workflow’s inputs object.
Arazzo Parameter Object Examples
parameters: - reference: $components.parameters.authorization - name: name in: query value: $inputs.drink_name - name: type in: query value: $inputs.drink_type - name: price in: query value: $inputs.drink_price_usd_cent - name: ingredients in: query value: $inputs.ingredientsSuccess Action Object
A success action object defines an action to take when a workflow step succeeds.
namestringsuccessActions array of a step or workflow.typestringend- End the workflow.goto- Move to another step in the workflow. Requires eitherstepIdorworkflowIdto be specified.
stepIdstringstepId of the step to execute next if type is goto. Mutually exclusive with workflowId.workflowIdstringworkflowId of the workflow to execute if type is goto. Mutually exclusive with stepId.criteriax-*Below is an example of a success action object:
onSuccess: - name: printReceipt type: goto workflowId: $sourceDescriptions.printsAndBeeps.printReceipt criteria: - type: simple condition: $checkStatus.status == 'completed'Failure Action Object
A failure action object defines an action to take when a workflow step fails.
namestringfailureActions array of a step or workflow.typestringend- End the workflow, returning the specifiedoutputsif provided.goto- Move to another step in the workflow. Requires eitherstepIdorworkflowIdto be specified.retry- Retry the failed step. RequiresretryAfterand optionallyretryLimitto be specified.
stepIdstringstepId of the step to execute next if type is goto. Mutually exclusive with workflowId.workflowIdstringworkflowId of the workflow to execute if type is goto. Mutually exclusive with stepId.retryAftertype is retry. Must be a non-negative integer. The specification is ambiguous about whether this field also applies when type is goto.retryLimittype is retry. Must be a non-negative integer. If not provided, the step will be retried indefinitely until it succeeds or the workflow is canceled.criteriax-*Below is an example of a failure action object:
onFailure: - name: beepLoudly type: goto workflowId: $sourceDescriptions.printsAndBeeps.beepLoudly criteria: - type: simple condition: $checkStatus.status == 'failed'Components Object
The components object holds reusable objects that can be referenced from other parts of the Arazzo description.
inputsstring, JSON Schema]inputs.parametersstring, Parameter Object]successActionsstring, Success Action Object]failureActionsstring, Failure Action Object]x-*The keys in the components object may only contain alphanumeric characters, underscores, and dashes.
Arazzo Components Object Example
components: inputs: authenticate: type: object properties: username: type: string password: type: string parameters: authorization: name: Authorization in: header value: $authenticate.outputs.token username: name: username in: body value: $inputs.username password: name: password in: body value: $inputs.passwordThe components defined in an Arazzo description are scoped to that document. Components defined in one Arazzo description cannot be referenced from another Arazzo description.
Reusable Object
A reusable object allows you to reference objects like success actions and failure actions defined in the components object from locations within steps or workflows.
referencecomponents object.valueArazzo Reusable Object Example
- reference: $components.parameters.username value: admin- reference: $components.parameters.passwordCriterion Object
A criterion object is used to specify assertions in the successCriteria field of a step object, or the criteria field of a success action object or failure action object.
Criterion objects support three types of assertions:
simple- Basic comparisons using literals, operators, and runtime expressions. This is the default if notypeis specified.regex- Applies a regular expression pattern to a context defined by a runtime expression.JSONPath- Applies a JSONPath expression to a context defined by a runtime expression. The root node of the JSONPath is the context.
Literals
Literals are constant values that can be used in simple conditions. The following data types are supported:
booleantrue or falsenullnullnumberint32, int64, float, or double.stringOperators
Simple conditions support the following operators:
<<=>>===!=!&&||()[].String comparisons are case-insensitive.
A criterion object consists of the following fields:
contextregex and JSONPath conditions. Must be provided if type is specified.conditionstringsimple conditions, combines literals, operators, and runtime expressions. For regex and JSONPath conditions, provides the expression to evaluate against the context.typestringsimple, regex, or JSONPath. Defaults to simple if not provided.x-*Arazzo Criterion Object Examples
Simple Condition - Check if a drink was successfully created
- condition: $statusCode == 201Simple Condition - Check if the bar is open
- condition: $response.body#/isOpen == trueRegex Condition - Check if the drink name matches a pattern
- context: $response.body#/drinkName condition: "^Sazerac" type: regexJSONPath Condition - Check if the ingredient list contains “whiskey”
- context: $response.body condition: $..ingredients[?(@.name == 'whiskey')] type: JSONPathSimple Condition - Check if the customer is over 21
- condition: $response.body#/customer/age >= 21JSONPath Condition - Check if there are any available tables
- context: $response.body condition: $[?length(@.tables[?(@.available == true)]) > 0] type: JSONPathRequest Body Object
The request body object describes the payload and Content-Type to send with the request when executing an operation in a workflow step.
contentTypestringContent-Type header for the request payload. If omitted, defaults to the Content-Type of the referenced operation.payloadreplacementsx-*Request Body Object Examples
JSON Payload (Template)
contentType: application/jsonpayload: | { "order": { "drinkId": "{$inputs.drink_id}", "customerId": "{$inputs.customer_id}", "quantity": {$inputs.quantity} } }JSON Payload (Object)
contentType: application/jsonpayload: order: drinkId: $inputs.drink_id customerId: $inputs.customer_id quantity: $inputs.quantityJSON Payload (Runtime Expression)
contentType: application/jsonpayload: $inputs.orderPayloadXML Payload (Template)
contentType: application/xmlpayload: | <order> <drinkId>{$inputs.drink_id}</drinkId> <customerId>{$inputs.customer_id}</customerId> <quantity>{$inputs.quantity}</quantity> </order>Form Data Payload (Object)
contentType: application/x-www-form-urlencodedpayload: drinkId: $inputs.drink_id customerId: $inputs.customer_id quantity: $inputs.quantityForm Data Payload (String)
contentType: application/x-www-form-urlencodedpayload: "drinkId={$inputs.drink_id}&customerId={$inputs.customer_id}&quantity={$inputs.quantity}"Payload Replacement Object
A payload replacement object specifies a location within the request payload and the value to insert at that location.
targetstringvalue. For JSON payloads, use JSON Pointer. For XML payloads, use XPath.valuetarget location. Can be a literal or a runtime expression that will be evaluated before sending the request.x-*Payload Replacement Object Examples
Runtime Expression Value
target: /drinkIdvalue: $inputs.drink_idLiteral Value
target: /quantityvalue: 2Runtime Expressions
Runtime expressions allow you to reference values that will be available when a workflow is executed, such as values from the HTTP request or response, the event that triggered the workflow, or outputs from previous workflow steps.
The syntax for runtime expressions is {expression}, where expression is one of the following:
$url$method$statusCode$request.header.{name}$request.query.{name}$request.path.{name}$request.body$request.body#/path/to/property$response.header.{name}$response.body$response.body#/path/to/property$inputs.{name}$outputs.{name}$steps.{stepId}.{outputName}{stepId}$workflows.{id}.{inputName}{id}$workflows.{id}.{outputName}{id}Runtime Expression Examples
$request.header.AuthorizationBearer abc123$request.query.drinkId12345$response.body#/drinks/0/name"Negroni"$inputs.orderType"pickup"$steps.submitOrder.outputs.orderId"a8b9c6d4e5f001"Arazzo Specification Extensions
The Arazzo Specification allows custom properties to be added at certain points using specification extensions.
Extension properties are always prefixed by "x-" and can have any valid JSON value.
For example:
x-internal-id: abc123x-vendor-parameter: vendorId: 123 channelId: abcThe extensions defined by the Arazzo Specification are:
info objectThe specification extension key formats ^x-oai- and ^x-oas- are reserved for extensions defined by the OpenAPI Initiative.
Extension properties can be used to add additional features, metadata, or configuration options to the Arazzo description that are not directly supported by the current version of the specification. However, additional tooling may be required to process custom extensions.