fix: allow function names and keywords as JSONPath member names in Arazzo criteria

Merged
TR
5d ago
+58-13

Why

openapi arazzo validate rejected valid RFC 9535 JSONPath criteria that use a function name or keyword as a member name, such as $.value[0], $.value[?(@.id == 'x')] or $.true. Microsoft Graph and OData list responses put their arrays under value, so this broke a lot of real workflows. Thanks to @kinlane for the report, found via arazzo-conformance.

The bug was in the jsonpath tokenizer and is fixed upstream in speakeasy-api/jsonpath#27 (released as v0.7.1).

Closes #301

What changed

  • Bumped github.com/speakeasy-api/jsonpath to v0.7.1 in the root and cmd/openapi modules. The other workspace modules only had go.sum updates from mise run mod-tidy.
  • Added TestCriterion_Validate_JsonPathKeywordMemberNames_Success, covering the conditions from the issue plus length/keyword member names and a real value() function call.
  • Updated the expected-error ignore string for the Ritza stress test. $.length == 5 is still rejected (a comparison outside a filter isn't valid RFC 9535), but the error now points at the == (column 9) instead of the space after length (column 8).

Review notes

  • One stricter behaviour arrives with v0.7.1: an unknown function such as $[?foo(@.a) > 1] used to be silently treated as length() and is now a parse error. That matches RFC 9535, but it could surface new validation errors on documents that were relying on it.

Testing

  • mise ci passed locally (format, mod-check, lint, README examples, tests, CLI integration tests, build).
  • Ran the #301 repro through openapi arazzo validate: it fails on v0.7.0 and validates cleanly on the fixed jsonpath.

Summary by cubic

Fixes openapi arazzo validate rejecting valid RFC 9535 JSONPath criteria that use function names or keywords as member names, such as $.value[0], $.value[?(@.id == 'x')], or $.true. This broke real workflows, since Microsoft Graph and OData list responses put arrays under value. The fix bumps github.com/speakeasy-api/jsonpath to v0.7.1, adds tests covering keyword and function-name member names (value, length, count, match, search), and updates the expected error string for the Ritza stress test. One stricter behavior arrives with the bump: unknown functions like $[?foo(@.a) > 1] were silently treated as length() and are now a parse error, matching RFC 9535, so documents relying on that would now fail validation. Closes #301.