...
1 package jsonschemax
2
3 import (
4 "fmt"
5 "testing"
6
7 "github.com/stretchr/testify/require"
8 )
9
10 func TestJSONPointerToDotNotation(t *testing.T) {
11 for k, tc := range [][]string{
12 {"#/foo/bar/baz", "foo.bar.baz"},
13 {"#/baz", "baz"},
14 {"#/properties/ory.sh~1kratos/type", "properties.ory\\.sh/kratos.type"},
15 } {
16 t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
17 path, err := JSONPointerToDotNotation(tc[0])
18 require.NoError(t, err)
19 require.Equal(t, tc[1], path)
20 })
21 }
22
23 _, err := JSONPointerToDotNotation("http://foo/#/bar")
24 require.Error(t, err, "should fail because remote pointers are not supported")
25
26 _, err = JSONPointerToDotNotation("http://foo/#/bar%zz")
27 require.Error(t, err, "should fail because %3b is not a valid escaped path.")
28 }
29
View as plain text