Skip to content

Commit e0b372f

Browse files
authored
Merge pull request #36 from JaredCE/json-path-rules
Json path rules
2 parents 4eb9bce + 4e51262 commit e0b372f

File tree

6 files changed

+121
-209
lines changed

6 files changed

+121
-209
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ Work on Reporting still needs completeing.
240240

241241
Accessing an OpenAPI operation by Operation Path `'{$sourceDescriptions.petstoreDescription.url}#/paths/~1pet~1findByStatus/get'` does not work currently
242242

243-
### JSONPath and XPath criteria objects
243+
### XPath criteria objects
244244

245-
Criteria Objects set as type JSON Path or XPath do not work
245+
Criteria Objects set as type XPath do not work
246246

247247
### Non application/json Responses
248248

package-lock.json

Lines changed: 17 additions & 153 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "arazzo-runner",
3-
"version": "0.0.13",
3+
"version": "0.0.14",
44
"description": "A runner to run through Arazzo Document workflows",
55
"main": "index.js",
66
"scripts": {
@@ -39,9 +39,9 @@
3939
"@redocly/openapi-core": "^2.14.5",
4040
"@swaggerexpert/arazzo-runtime-expression": "^1.0.1",
4141
"@swaggerexpert/json-pointer": "^2.10.2",
42+
"@swaggerexpert/jsonpath": "^4.0.1",
4243
"ajv": "^8.17.1",
4344
"fast-xml-parser": "^5.3.3",
44-
"jsonpath": "^1.1.1",
4545
"openapi-params": "^0.0.5",
4646
"openapi-server-url-templating": "^1.3.0",
4747
"openid-client": "^6.8.1",

src/Expression.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const {
1212
extract,
1313
} = require("@swaggerexpert/arazzo-runtime-expression");
1414
const { evaluate } = require("@swaggerexpert/json-pointer");
15-
const jp = require("jsonpath");
15+
const { evaluate: jsonPathEvaluate } = require("@swaggerexpert/jsonpath");
1616

1717
/**
1818
* Handles resolution of Arazzo runtime expressions to context values.
@@ -94,8 +94,11 @@ class Expression {
9494
checkJSONPathExpression(expression, jsonPath) {
9595
try {
9696
const value = this.resolveExpression(expression);
97-
return jp.query(value, jsonPath);
97+
const result = jsonPathEvaluate(value, jsonPath);
98+
99+
return Array.isArray(result) && result.length > 0;
98100
} catch (e) {
101+
console.error(e);
99102
return null;
100103
}
101104
}

0 commit comments

Comments
 (0)