Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arazzo-runner",
"version": "0.0.21",
"version": "0.0.22",
"description": "A runner to run through Arazzo Document workflows",
"main": "index.js",
"scripts": {
Expand Down
15 changes: 13 additions & 2 deletions src/Operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,20 @@ class Operation {

this.expression.addToContext("response.body", json);
} else {
const body = await response.body;
if (response.headers.has("Content-Type") && ['application/xml', 'text/xml', 'text/plain', 'text/html'].includes(response.headers.get("Content-Type"))) {
const data = await response?.text().catch(err => {
this.logger.error(
`Error trying to resolve ${this.step.stepId} outputs`,
);
throw new Error(err);
})

this.expression.addToContext("response.body", data);
} else {
const body = await response.body;
this.expression.addToContext("response.body", body);
}

this.expression.addToContext("response.body", body);
}
}

Expand Down
93 changes: 93 additions & 0 deletions test/mocks/arazzo/arazzo-criteria/jsonPath.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"$schema": "https://spec.openapis.org/arazzo/1.0/schema/2025-10-15",
"arazzo": "1.0.1",
"info": {
"title": "users",
"description": "The Arazzo Workflow for a Pet Store User",
"summary": "Araazo Workflow for Pet Store User",
"version": "1.0.0"
},
"sourceDescriptions": [
{
"name": "users-openAPI",
"url": "https://raw.githubusercontent.com/JaredCE/Arazzo-Runner/refs/heads/main/test/mocks/openapi/security/api-key/users-openapi.json",
"type": "openapi"
},
{
"name": "pets-openAPI",
"url": "https://raw.githubusercontent.com/JaredCE/Arazzo-Runner/refs/heads/main/test/mocks/openapi/pet-openapi.json",
"type": "openapi"
}
],
"workflows": [
{
"workflowId": "getPets",
"summary": "gets pets by Tag",
"description": "Logs the user in and then gets pets",
"inputs": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"steps": [
{
"stepId": "LoginExistingUser",
"operationId": "$sourceDescriptions.users-openAPI.loginUser",
"requestBody": {
"contentType": "application/json",
"payload": {
"username": "$inputs.username",
"password": "$inputs.password"
}
},
"outputs": {
"AccessToken": "$response.body#/AccessToken"
},
"successCriteria": [
{
"condition": "$statusCode == 200"
}
]
},
{
"stepId": "findPetsByTags",
"operationId": "$sourceDescriptions.pets-openAPI.findPetsByTags",
"parameters": [
{
"name": "Authorization",
"in": "header",
"value": "$steps.LoginExistingUser.outputs.AccessToken"
},
{
"name": "tags",
"in": "query",
"value": "$inputs.tags"
}
],
"successCriteria": [
{
"condition": "$statusCode == 200"
},
{
"type": "jsonpath",
"condition": "$[?(@.id == 1)]",
"context": "$response.body"
}
]
}
]
}
]
}
63 changes: 63 additions & 0 deletions test/mocks/arazzo/arazzo-criteria/regex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"$schema": "https://spec.openapis.org/arazzo/1.0/schema/2025-10-15",
"arazzo": "1.0.1",
"info": {
"title": "users",
"description": "The Arazzo Workflow for a Pet Store User",
"summary": "Araazo Workflow for Pet Store User",
"version": "1.0.0"
},
"sourceDescriptions": [
{
"name": "users-openAPI",
"url": "https://raw.githubusercontent.com/JaredCE/Arazzo-Runner/refs/heads/main/test/mocks/openapi/security/api-key/users-openapi.json",
"type": "openapi"
}
],
"workflows": [
{
"workflowId": "deleteCurrentUser-apiKey",
"summary": "Deletes the current user",
"description": "Logs the user in and then deletes them",
"inputs": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
"steps": [
{
"stepId": "LoginExistingUser",
"operationId": "loginUser",
"requestBody": {
"contentType": "application/json",
"payload": {
"username": "$inputs.username",
"password": "$inputs.password"
}
},
"outputs": {
"AccessToken": "$response.body#/AccessToken"
},
"successCriteria": [
{
"type": "regex",
"condition": "^200$",
"context": "$statusCode"
},
{
"type": "regex",
"condition": "(^[A-Za-z0-9-_]*\\.[A-Za-z0-9-_]*\\.[A-Za-z0-9-_]*$)",
"context": "$response.body#/AccessToken"
}
]
}
]
}
]
}
56 changes: 56 additions & 0 deletions test/mocks/arazzo/arazzo-criteria/simple.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "https://spec.openapis.org/arazzo/1.0/schema/2025-10-15",
"arazzo": "1.0.1",
"info": {
"title": "users",
"description": "The Arazzo Workflow for a Pet Store User",
"summary": "Araazo Workflow for Pet Store User",
"version": "1.0.0"
},
"sourceDescriptions": [
{
"name": "users-openAPI",
"url": "https://raw.githubusercontent.com/JaredCE/Arazzo-Runner/refs/heads/main/test/mocks/openapi/security/api-key/users-openapi.json",
"type": "openapi"
}
],
"workflows": [
{
"workflowId": "deleteCurrentUser-apiKey",
"summary": "Deletes the current user",
"description": "Logs the user in and then deletes them",
"inputs": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
"steps": [
{
"stepId": "LoginExistingUser",
"operationId": "loginUser",
"requestBody": {
"contentType": "application/json",
"payload": {
"username": "$inputs.username",
"password": "$inputs.password"
}
},
"outputs": {
"AccessToken": "$response.body#/AccessToken"
},
"successCriteria": [
{
"condition": "$statusCode == 200"
}
]
}
]
}
]
}
93 changes: 93 additions & 0 deletions test/mocks/arazzo/arazzo-criteria/xPath.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"$schema": "https://spec.openapis.org/arazzo/1.0/schema/2025-10-15",
"arazzo": "1.0.1",
"info": {
"title": "users",
"description": "The Arazzo Workflow for a Pet Store User",
"summary": "Araazo Workflow for Pet Store User",
"version": "1.0.0"
},
"sourceDescriptions": [
{
"name": "users-openAPI",
"url": "https://raw.githubusercontent.com/JaredCE/Arazzo-Runner/refs/heads/main/test/mocks/openapi/security/api-key/users-openapi.json",
"type": "openapi"
},
{
"name": "pets-openAPI",
"url": "https://raw.githubusercontent.com/JaredCE/Arazzo-Runner/refs/heads/main/test/mocks/openapi/pet-openapi.json",
"type": "openapi"
}
],
"workflows": [
{
"workflowId": "getPets",
"summary": "gets pets by Tag",
"description": "Logs the user in and then gets pets",
"inputs": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"steps": [
{
"stepId": "LoginExistingUser",
"operationId": "$sourceDescriptions.users-openAPI.loginUser",
"requestBody": {
"contentType": "application/json",
"payload": {
"username": "$inputs.username",
"password": "$inputs.password"
}
},
"outputs": {
"AccessToken": "$response.body#/AccessToken"
},
"successCriteria": [
{
"condition": "$statusCode == 200"
}
]
},
{
"stepId": "findPetsByTags",
"operationId": "$sourceDescriptions.pets-openAPI.findPetsByTags",
"parameters": [
{
"name": "Authorization",
"in": "header",
"value": "$steps.LoginExistingUser.outputs.AccessToken"
},
{
"name": "tags",
"in": "query",
"value": "$inputs.tags"
}
],
"successCriteria": [
{
"condition": "$statusCode == 200"
},
{
"type": "xpath",
"condition": "//pet[id = '1']",
"context": "$response.body"
}
]
}
]
}
]
}
9 changes: 9 additions & 0 deletions test/mocks/inputs/criteria/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"getPets": {
"username": "DannyB",
"password": "P4ssW0rd",
"tags": [
"found"
]
}
}
Loading