Skip to content

replace jsonpath-plus with jsonata#30

Merged
massfords merged 4 commits into
mainfrom
mf/jsonata
Sep 7, 2025
Merged

replace jsonpath-plus with jsonata#30
massfords merged 4 commits into
mainfrom
mf/jsonata

Conversation

@massfords
Copy link
Copy Markdown
Owner

I'm removing the JSONPath library in favor or using JSONata instead. The JSONPath expressions are nicer but this library has had some vulnerabilities requiring hot fixes and the asl-validator is already using JSONata so it would be best to remove the dependency

The breaking change is that the JSONata expression evaluation is asynchronous so the AJV format and its schemas must be configured to be asynchronous.

Comment thread src/__tests__/ajv.test.ts
Comment on lines -15 to +16
schemas: [example, payloadTemplateSchema],
schemas: [
{ ...example, $async: true },
{ ...payloadTemplateSchema, $async: true },
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each of the schemas has to be flagged as being async since they may contain formats that are validated by async functions

Comment thread src/__tests__/ajv.test.ts
Comment on lines -46 to +52
const result = ajv.validate(
"https://asl-path-validator.cloud/example.json#",
input
const validator = ajv.getSchema(
"https://asl-path-validator.cloud/example.json#"
);
must(validator);
const result = await validator(input);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slight change in how async validations are done

we can't use the top level validate function on AJV since that it synchronous. Instead, we get the validator function for the schema and invoke it as an asynchronous function.

The result is the input when no error or it throws. This will be another required change on how this is used in asl-validator

@massfords massfords merged commit 8f7ea07 into main Sep 7, 2025
1 check passed
@massfords massfords deleted the mf/jsonata branch September 7, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant