diff --git a/arazzo/arazzo_test.go b/arazzo/arazzo_test.go index 2f0f1b52..3ed9a2ca 100644 --- a/arazzo/arazzo_test.go +++ b/arazzo/arazzo_test.go @@ -671,7 +671,7 @@ var stressTests = []struct { args: args{ location: "https://raw.githubusercontent.com/ritza-co/e2e-testing-arazzo/c0615c3708a1e4c0fcaeb79edae78ddc4eb5ba82/arazzo.yaml", validationIgnores: []string{ - "[42:24] error validation-invalid-syntax invalid jsonpath expression: Error at line 1, column 8: unexpected token", // legit invalid RFC 9535 syntax + "[42:24] error validation-invalid-syntax invalid jsonpath expression: Error at line 1, column 9: unexpected token when parsing segment", // legit invalid RFC 9535 syntax }, }, wantTitle: "Build-a-Bot Workflow", diff --git a/arazzo/criterion/criterion_validate_test.go b/arazzo/criterion/criterion_validate_test.go index 0b328871..d4789d3e 100644 --- a/arazzo/criterion/criterion_validate_test.go +++ b/arazzo/criterion/criterion_validate_test.go @@ -474,3 +474,48 @@ func TestCriterion_Validate_WithTypes(t *testing.T) { }) } } + +func TestCriterion_Validate_JsonPathKeywordMemberNames_Success(t *testing.T) { + t.Parallel() + + // RFC 9535 member-name-shorthand allows function names (value, length, count, + // match, search) and keywords (true, false, null) as member names. + tests := []struct { + name string + condition string + }{ + {name: "value member followed by index", condition: "$.value[0]"}, + {name: "value member followed by wildcard", condition: "$.value[*]"}, + {name: "value member followed by filter", condition: "$.value[?(@.id == 'x')]"}, + {name: "value member followed by child", condition: "$.value.id"}, + {name: "descendant value member", condition: "$..value[0]"}, + {name: "value member inside filter query", condition: "$[?@.value[0] == 1]"}, + {name: "length member followed by index", condition: "$.length[0]"}, + {name: "count member followed by index", condition: "$.count[0]"}, + {name: "match member followed by index", condition: "$.match[0]"}, + {name: "search member followed by index", condition: "$.search[0]"}, + {name: "keyword members", condition: "$.true.false.null"}, + {name: "value function call", condition: "$[?value(@.a) == 1]"}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + + c := &criterion.Criterion{ + Context: pointer.From(expression.Expression("$response.body")), + Condition: tt.condition, + Type: criterion.CriterionTypeUnion{ + Type: pointer.From(criterion.CriterionTypeJsonPath), + }, + } + + err := c.Sync(t.Context()) + require.NoError(t, err, "sync should succeed") + + errs := c.Validate() + assert.Empty(t, errs, "validation should succeed") + assert.True(t, c.Valid, "criterion should be valid") + }) + } +} diff --git a/cmd/openapi/go.mod b/cmd/openapi/go.mod index ca249557..98bb22d5 100644 --- a/cmd/openapi/go.mod +++ b/cmd/openapi/go.mod @@ -36,7 +36,7 @@ require ( github.com/muesli/cancelreader v0.2.2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 // indirect - github.com/speakeasy-api/jsonpath v0.7.0 // indirect + github.com/speakeasy-api/jsonpath v0.7.1 // indirect github.com/speakeasy-api/yaml-jsonpath v0.0.0-20261016002013-07e5f48e6d17 // indirect github.com/spf13/pflag v1.0.9 // indirect github.com/xo/terminfo v1.0.0 // indirect diff --git a/cmd/openapi/go.sum b/cmd/openapi/go.sum index 3200b4c8..8983a780 100644 --- a/cmd/openapi/go.sum +++ b/cmd/openapi/go.sum @@ -68,8 +68,8 @@ github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57Hu github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/speakeasy-api/jsonpath v0.7.0 h1:Pz7dS2AfuB745mnEcmg4qyS7wTJFiHH9zjW5kFX9b4E= -github.com/speakeasy-api/jsonpath v0.7.0/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= +github.com/speakeasy-api/jsonpath v0.7.1 h1:vpBDKeT6av0v/g6oTwCfGh27iRDfMPaTQ2GvKK51TkQ= +github.com/speakeasy-api/jsonpath v0.7.1/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= github.com/speakeasy-api/openapi v1.26.3-0.20261102103018-bb4439a5fcc1 h1:/7XBrBdRjH+V1SisA55rzT9Q2+f8DzlpXKkzNeJdzQE= github.com/speakeasy-api/openapi v1.26.3-0.20261102103018-bb4439a5fcc1/go.mod h1:mBpPJFcBwcARRpedUYhZY3tzWFZ19eJKtZGUJsc+KW0= github.com/speakeasy-api/openapi/openapi/linter/customrules v0.0.0-20261102103018-bb4439a5fcc1 h1:W27n3pNt9dNSCPF9nV0CFiCkNaEt3fUTZtAcGdcWJKo= diff --git a/go.mod b/go.mod index 63566b58..46294159 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.26.0 require ( github.com/blackwell-systems/gcf-go v1.8.0 github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 - github.com/speakeasy-api/jsonpath v0.7.0 + github.com/speakeasy-api/jsonpath v0.7.1 github.com/speakeasy-api/yaml-jsonpath v0.0.0-20261016002013-07e5f48e6d17 github.com/stretchr/testify v1.12.1 go.yaml.in/yaml/v3 v3.0.6 diff --git a/go.sum b/go.sum index d42a93fa..4fcb9049 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57Hu github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/speakeasy-api/jsonpath v0.7.0 h1:Pz7dS2AfuB745mnEcmg4qyS7wTJFiHH9zjW5kFX9b4E= -github.com/speakeasy-api/jsonpath v0.7.0/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= +github.com/speakeasy-api/jsonpath v0.7.1 h1:vpBDKeT6av0v/g6oTwCfGh27iRDfMPaTQ2GvKK51TkQ= +github.com/speakeasy-api/jsonpath v0.7.1/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= github.com/speakeasy-api/yaml-jsonpath v0.0.0-20261016002013-07e5f48e6d17 h1:GczZJYqsf1WvvdkFvviAaP5wLrqxRPed8TmbKFsoLFk= github.com/speakeasy-api/yaml-jsonpath v0.0.0-20261016002013-07e5f48e6d17/go.mod h1:EMfEapMn2EVhphaczz62z+JnkJgCFixiF1G7z3tUbzg= github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= diff --git a/jsonschema/oas3/tests/go.sum b/jsonschema/oas3/tests/go.sum index 450f5ffc..04913839 100644 --- a/jsonschema/oas3/tests/go.sum +++ b/jsonschema/oas3/tests/go.sum @@ -86,8 +86,8 @@ github.com/shirou/gopsutil/v4 v4.26.6 h1:Mzr/npDtQC/xpeEuQKHZt8Zo9CmPvhTj8nkR8w5 github.com/shirou/gopsutil/v4 v4.26.6/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ= github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w= github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g= -github.com/speakeasy-api/jsonpath v0.7.0 h1:Pz7dS2AfuB745mnEcmg4qyS7wTJFiHH9zjW5kFX9b4E= -github.com/speakeasy-api/jsonpath v0.7.0/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= +github.com/speakeasy-api/jsonpath v0.7.1 h1:vpBDKeT6av0v/g6oTwCfGh27iRDfMPaTQ2GvKK51TkQ= +github.com/speakeasy-api/jsonpath v0.7.1/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= diff --git a/openapi/linter/converter/tests/go.sum b/openapi/linter/converter/tests/go.sum index 04c3c65c..6bc89fe4 100644 --- a/openapi/linter/converter/tests/go.sum +++ b/openapi/linter/converter/tests/go.sum @@ -12,8 +12,8 @@ github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28= github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= -github.com/speakeasy-api/jsonpath v0.7.0 h1:Pz7dS2AfuB745mnEcmg4qyS7wTJFiHH9zjW5kFX9b4E= -github.com/speakeasy-api/jsonpath v0.7.0/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= +github.com/speakeasy-api/jsonpath v0.7.1 h1:vpBDKeT6av0v/g6oTwCfGh27iRDfMPaTQ2GvKK51TkQ= +github.com/speakeasy-api/jsonpath v0.7.1/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM= diff --git a/openapi/linter/customrules/go.sum b/openapi/linter/customrules/go.sum index 04c3c65c..6bc89fe4 100644 --- a/openapi/linter/customrules/go.sum +++ b/openapi/linter/customrules/go.sum @@ -12,8 +12,8 @@ github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28= github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= -github.com/speakeasy-api/jsonpath v0.7.0 h1:Pz7dS2AfuB745mnEcmg4qyS7wTJFiHH9zjW5kFX9b4E= -github.com/speakeasy-api/jsonpath v0.7.0/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= +github.com/speakeasy-api/jsonpath v0.7.1 h1:vpBDKeT6av0v/g6oTwCfGh27iRDfMPaTQ2GvKK51TkQ= +github.com/speakeasy-api/jsonpath v0.7.1/go.mod h1:b9upx/gIKYwyKVcgRxvmdyKwAykzk88FCnNH3cwbw8w= github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=