diff --git a/go.mod b/go.mod index a951184..2950004 100644 --- a/go.mod +++ b/go.mod @@ -3,16 +3,17 @@ module github.com/speakeasy-api/openapi-overlay go 1.22 require ( - github.com/speakeasy-api/jsonpath v0.5.0 + github.com/speakeasy-api/jsonpath v0.6.0 github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.9.0 + github.com/vmware-labs/yaml-jsonpath v0.3.2 gopkg.in/yaml.v3 v3.0.1 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/kr/text v0.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect ) diff --git a/go.sum b/go.sum index ca3b779..a6cfe7f 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,13 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960 h1:aRd8M7HJVZOqn/vhOzrGcQH0lNAMkqMn+pXUYkatmcA= +github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960/go.mod h1:9HQzr9D/0PGwMEbC3d5AB7oi67+h4TsQqItC1GVYG58= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -8,19 +15,48 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.2 h1:uqH7bpe+ERSiDa34FDOF7RikN6RzXgduUF8yarlZp94= +github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= +github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/speakeasy-api/jsonpath v0.5.0 h1:hc6XlmFROc2a14XyQAZmSUQO+cuShq9TyevPEElINII= -github.com/speakeasy-api/jsonpath v0.5.0/go.mod h1:ymb2iSkyOycmzKwbEAYPJV/yi2rSmvBCLZJcyD+VVWw= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/speakeasy-api/jsonpath v0.6.0 h1:IhtFOV9EbXplhyRqsVhHoBmmYjblIRh5D1/g8DHMXJ8= +github.com/speakeasy-api/jsonpath v0.6.0/go.mod h1:ymb2iSkyOycmzKwbEAYPJV/yi2rSmvBCLZJcyD+VVWw= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk= +github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/overlay/apply.go b/pkg/overlay/apply.go index f903b23..36c3351 100644 --- a/pkg/overlay/apply.go +++ b/pkg/overlay/apply.go @@ -2,8 +2,8 @@ package overlay import ( "fmt" - "github.com/speakeasy-api/jsonpath/pkg/jsonpath" "github.com/speakeasy-api/jsonpath/pkg/jsonpath/config" + "github.com/speakeasy-api/jsonpath/pkg/jsonpath/token" "gopkg.in/yaml.v3" "strings" ) @@ -14,9 +14,9 @@ func (o *Overlay) ApplyTo(root *yaml.Node) error { for _, action := range o.Actions { var err error if action.Remove { - err = applyRemoveAction(root, action) + err = o.applyRemoveAction(root, action, nil) } else { - err = applyUpdateAction(root, action, &[]string{}) + err = o.applyUpdateAction(root, action, &[]string{}) } if err != nil { @@ -30,33 +30,46 @@ func (o *Overlay) ApplyTo(root *yaml.Node) error { func (o *Overlay) ApplyToStrict(root *yaml.Node) (error, []string) { multiError := []string{} warnings := []string{} + hasFilterExpression := false for i, action := range o.Actions { - err := validateSelectorHasAtLeastOneTarget(root, action) + tokens := token.NewTokenizer(action.Target, config.WithPropertyNameExtension()).Tokenize() + for _, tok := range tokens { + if tok.Token == token.FILTER { + hasFilterExpression = true + } + } + + actionWarnings := []string{} + err := o.validateSelectorHasAtLeastOneTarget(root, action) if err != nil { multiError = append(multiError, err.Error()) } if action.Remove { - err = applyRemoveAction(root, action) + err = o.applyRemoveAction(root, action, &actionWarnings) } else { - actionWarnings := []string{} - err = applyUpdateAction(root, action, &actionWarnings) - for _, warning := range actionWarnings { - warnings = append(warnings, fmt.Sprintf("update action (%v / %v) target=%s: %s", i+1, len(o.Actions), action.Target, warning)) - } + err = o.applyUpdateAction(root, action, &actionWarnings) } + for _, warning := range actionWarnings { + warnings = append(warnings, fmt.Sprintf("update action (%v / %v) target=%s: %s", i+1, len(o.Actions), action.Target, warning)) + } + } + + if hasFilterExpression && !o.UsesRFC9535() { + warnings = append(warnings, "overlay has a filter expression but lacks `x-speakeasy-jsonpath: rfc9535` extension. Deprecated jsonpath behaviour in use. See overlay.speakeasy.com for the implementation playground.") } + if len(multiError) > 0 { return fmt.Errorf("error applying overlay (strict): %v", strings.Join(multiError, ",")), warnings } return nil, warnings } -func validateSelectorHasAtLeastOneTarget(root *yaml.Node, action Action) error { +func (o *Overlay) validateSelectorHasAtLeastOneTarget(root *yaml.Node, action Action) error { if action.Target == "" { return nil } - p, err := jsonpath.NewPath(action.Target) + p, err := o.NewPath(action.Target, nil) if err != nil { return err } @@ -70,14 +83,14 @@ func validateSelectorHasAtLeastOneTarget(root *yaml.Node, action Action) error { return nil } -func applyRemoveAction(root *yaml.Node, action Action) error { +func (o *Overlay) applyRemoveAction(root *yaml.Node, action Action, warnings *[]string) error { if action.Target == "" { return nil } idx := newParentIndex(root) - p, err := jsonpath.NewPath(action.Target, config.WithPropertyNameExtension()) + p, err := o.NewPath(action.Target, warnings) if err != nil { return err } @@ -104,8 +117,13 @@ func removeNode(idx parentIndex, node *yaml.Node) { if child == node { switch parent.Kind { case yaml.MappingNode: - // we have to delete the key too - parent.Content = append(parent.Content[:i-1], parent.Content[i+1:]...) + if i%2 == 1 { + // if we select a value, we should delete the key too + parent.Content = append(parent.Content[:i-1], parent.Content[i+1:]...) + } else { + // if we select a key, we should delete the value + parent.Content = append(parent.Content[:i], parent.Content[i+2:]...) + } return case yaml.SequenceNode: parent.Content = append(parent.Content[:i], parent.Content[i+1:]...) @@ -115,7 +133,7 @@ func removeNode(idx parentIndex, node *yaml.Node) { } } -func applyUpdateAction(root *yaml.Node, action Action, warnings *[]string) error { +func (o *Overlay) applyUpdateAction(root *yaml.Node, action Action, warnings *[]string) error { if action.Target == "" { return nil } @@ -124,7 +142,7 @@ func applyUpdateAction(root *yaml.Node, action Action, warnings *[]string) error return nil } - p, err := jsonpath.NewPath(action.Target, config.WithPropertyNameExtension()) + p, err := o.NewPath(action.Target, warnings) if err != nil { return err } diff --git a/pkg/overlay/apply_test.go b/pkg/overlay/apply_test.go index 1f253ff..6c95c6e 100644 --- a/pkg/overlay/apply_test.go +++ b/pkg/overlay/apply_test.go @@ -2,6 +2,7 @@ package overlay_test import ( "bytes" + "github.com/speakeasy-api/jsonpath/pkg/jsonpath" "github.com/speakeasy-api/openapi-overlay/pkg/loader" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -75,3 +76,42 @@ func TestApplyToStrict(t *testing.T) { assert.Equal(t, "update action (2 / 2) target=$.info.title: does nothing", warnings[0]) NodeMatchesFile(t, node, "testdata/openapi-strict-onechange.yaml") } + +func TestApplyToOld(t *testing.T) { + t.Parallel() + + nodeOld, err := loader.LoadSpecification("testdata/openapi.yaml") + require.NoError(t, err) + + nodeNew, err := loader.LoadSpecification("testdata/openapi.yaml") + require.NoError(t, err) + + o, err := loader.LoadOverlay("testdata/overlay-old.yaml") + require.NoError(t, err) + + err, warnings := o.ApplyToStrict(nodeOld) + require.NoError(t, err) + require.Len(t, warnings, 2) + require.Contains(t, warnings[0], "invalid rfc9535 jsonpath") + require.Contains(t, warnings[1], "x-speakeasy-jsonpath: rfc9535") + + path, err := jsonpath.NewPath(`$.paths["/anything/selectGlobalServer"]`) + require.NoError(t, err) + result := path.Query(nodeOld) + require.NoError(t, err) + require.Equal(t, 0, len(result)) + o.JSONPathVersion = "rfc9535" + err, warnings = o.ApplyToStrict(nodeNew) + require.ErrorContains(t, err, "unexpected token") // should error out: invalid nodepath + // now lets fix it. + o.Actions[0].Target = "$.paths.*[?(@[\"x-my-ignore\"])]" + err, warnings = o.ApplyToStrict(nodeNew) + require.ErrorContains(t, err, "did not match any targets") + // Now lets fix it. + o.Actions[0].Target = "$.paths[?(@[\"x-my-ignore\"])]" // @ should always refer to the child node in RFC 9535.. + err, warnings = o.ApplyToStrict(nodeNew) + require.NoError(t, err) + result = path.Query(nodeNew) + require.NoError(t, err) + require.Equal(t, 0, len(result)) +} diff --git a/pkg/overlay/compare.go b/pkg/overlay/compare.go index 1aa8d2f..33dff6a 100644 --- a/pkg/overlay/compare.go +++ b/pkg/overlay/compare.go @@ -18,7 +18,8 @@ func Compare(title string, y1 *yaml.Node, y2 yaml.Node) (*Overlay, error) { } return &Overlay{ - Version: "1.0.0", + Version: "1.0.0", + JSONPathVersion: "rfc9535", Info: Info{ Title: title, Version: "0.0.0", diff --git a/pkg/overlay/compare_test.go b/pkg/overlay/compare_test.go index 623a99a..e9a6d91 100644 --- a/pkg/overlay/compare_test.go +++ b/pkg/overlay/compare_test.go @@ -1,8 +1,8 @@ package overlay_test import ( - "github.com/speakeasy-api/jsonpath/pkg/overlay" "github.com/speakeasy-api/openapi-overlay/pkg/loader" + "github.com/speakeasy-api/openapi-overlay/pkg/overlay" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "os" diff --git a/pkg/overlay/jsonpath.go b/pkg/overlay/jsonpath.go new file mode 100644 index 0000000..d43617c --- /dev/null +++ b/pkg/overlay/jsonpath.go @@ -0,0 +1,47 @@ +package overlay + +import ( + "fmt" + "github.com/speakeasy-api/jsonpath/pkg/jsonpath" + "github.com/speakeasy-api/jsonpath/pkg/jsonpath/config" + "github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath" + "gopkg.in/yaml.v3" +) + +type Queryable interface { + Query(root *yaml.Node) []*yaml.Node +} + +type yamlPathQueryable struct { + path *yamlpath.Path +} + +func (y yamlPathQueryable) Query(root *yaml.Node) []*yaml.Node { + if y.path == nil { + return []*yaml.Node{} + } + // errors aren't actually possible from yamlpath. + result, _ := y.path.Find(root) + return result +} + +func (o *Overlay) NewPath(target string, warnings *[]string) (Queryable, error) { + rfcJSONPath, rfcJSONPathErr := jsonpath.NewPath(target, config.WithPropertyNameExtension()) + if o.UsesRFC9535() { + return rfcJSONPath, rfcJSONPathErr + } + if rfcJSONPathErr != nil && warnings != nil { + *warnings = append(*warnings, fmt.Sprintf("invalid rfc9535 jsonpath %s: %s\nThis will be treated as an error in the future. Please fix and opt into the new implementation with `\"x-speakeasy-jsonpath\": rfc9535` in the root of your overlay. See overlay.speakeasy.com for an implementation playground.", target, rfcJSONPathErr.Error())) + } + + path, err := yamlpath.NewPath(target) + return mustExecute(path), err +} + +func (o *Overlay) UsesRFC9535() bool { + return o.JSONPathVersion == "rfc9535" +} + +func mustExecute(path *yamlpath.Path) yamlPathQueryable { + return yamlPathQueryable{path} +} diff --git a/pkg/overlay/schema.go b/pkg/overlay/schema.go index db38422..f4408f0 100644 --- a/pkg/overlay/schema.go +++ b/pkg/overlay/schema.go @@ -13,10 +13,12 @@ type Extensions map[string]any type Overlay struct { Extensions `yaml:"-,inline"` - // Version is the version of the overlay configuration. As the RFC was never - // really ratifies, this value does not mean much. + // Version is the version of the overlay configuration. This is only ever expected to be 1.0.0 Version string `yaml:"overlay"` + // JSONPathVersion should be set to rfc9535, and is used for backwards compatability purposes + JSONPathVersion string `yaml:"x-speakeasy-jsonpath,omitempty"` + // Info describes the metadata for the overlay. Info Info `yaml:"info"` diff --git a/pkg/overlay/testdata/openapi-overlayed.yaml b/pkg/overlay/testdata/openapi-overlayed.yaml index fca09e6..32c9bbe 100644 --- a/pkg/overlay/testdata/openapi-overlayed.yaml +++ b/pkg/overlay/testdata/openapi-overlayed.yaml @@ -46,7 +46,7 @@ tags: - name: orders description: The orders endpoints. - name: authentication - description: The authentication endpoints. + x-something: else - name: config - name: Testing description: just a description diff --git a/pkg/overlay/testdata/openapi-strict-onechange.yaml b/pkg/overlay/testdata/openapi-strict-onechange.yaml index 4e3b7fb..8d0e302 100644 --- a/pkg/overlay/testdata/openapi-strict-onechange.yaml +++ b/pkg/overlay/testdata/openapi-strict-onechange.yaml @@ -47,6 +47,7 @@ tags: description: The orders endpoints. - name: authentication description: The authentication endpoints. + x-something: else - name: config paths: x-speakeasy-errors: diff --git a/pkg/overlay/testdata/openapi.yaml b/pkg/overlay/testdata/openapi.yaml index b4e9605..da1c1eb 100644 --- a/pkg/overlay/testdata/openapi.yaml +++ b/pkg/overlay/testdata/openapi.yaml @@ -47,6 +47,7 @@ tags: description: The orders endpoints. - name: authentication description: The authentication endpoints. + x-something: else - name: config paths: diff --git a/pkg/overlay/testdata/overlay-generated.yaml b/pkg/overlay/testdata/overlay-generated.yaml index 7e43c7f..5422849 100644 --- a/pkg/overlay/testdata/overlay-generated.yaml +++ b/pkg/overlay/testdata/overlay-generated.yaml @@ -1,10 +1,22 @@ overlay: 1.0.0 +x-speakeasy-jsonpath: rfc9535 info: title: Drinks Overlay version: 0.0.0 actions: + - target: $["tags"][*] + remove: true - target: $["tags"] update: + - name: drinks + description: The drinks endpoints. + - name: ingredients + description: The ingredients endpoints. + - name: orders + description: The orders endpoints. + - name: authentication + x-something: else + - name: config - name: Testing description: just a description - target: $["paths"]["/anything/selectGlobalServer"]["x-my-ignore"] diff --git a/pkg/overlay/testdata/overlay-mismatched.yaml b/pkg/overlay/testdata/overlay-mismatched.yaml index 4d9475a..c0e4f6f 100644 --- a/pkg/overlay/testdata/overlay-mismatched.yaml +++ b/pkg/overlay/testdata/overlay-mismatched.yaml @@ -1,4 +1,5 @@ overlay: 1.0.0 +x-speakeasy-jsonpath: rfc9535 info: title: Drinks Overlay version: 0.0.0 diff --git a/pkg/overlay/testdata/overlay-old.yaml b/pkg/overlay/testdata/overlay-old.yaml new file mode 100644 index 0000000..251f3c4 --- /dev/null +++ b/pkg/overlay/testdata/overlay-old.yaml @@ -0,0 +1,8 @@ +overlay: 1.0.0 +info: + title: Drinks Overlay + version: 1.2.3 + x-info-extension: 42 +actions: + - target: $.paths.*[?(@.x-my-ignore)] # this is non-compliant behaviour + remove: true diff --git a/pkg/overlay/testdata/overlay.yaml b/pkg/overlay/testdata/overlay.yaml index 2b9533d..60769f5 100644 --- a/pkg/overlay/testdata/overlay.yaml +++ b/pkg/overlay/testdata/overlay.yaml @@ -1,4 +1,5 @@ overlay: 1.0.0 +x-speakeasy-jsonpath: rfc9535 info: title: Drinks Overlay version: 1.2.3 @@ -35,6 +36,8 @@ actions: update: - name: Testing description: just a description + - target: $.tags[?(@.name == "authentication")].description~ + remove: true - target: $.paths["/anything/selectGlobalServer"]["x-my-ignore"] update: servers: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy