xref: /freebsd/contrib/libucl/tests/schema/ref.json (revision d9f0ce31)
1[
2    {
3        "description": "root pointer ref",
4        "schema": {
5            "properties": {
6                "foo": {"$ref": "#"}
7            },
8            "additionalProperties": false
9        },
10        "tests": [
11            {
12                "description": "match",
13                "data": {"foo": false},
14                "valid": true
15            },
16            {
17                "description": "recursive match",
18                "data": {"foo": {"foo": false}},
19                "valid": true
20            },
21            {
22                "description": "mismatch",
23                "data": {"bar": false},
24                "valid": false
25            },
26            {
27                "description": "recursive mismatch",
28                "data": {"foo": {"bar": false}},
29                "valid": false
30            }
31        ]
32    },
33    {
34        "description": "relative pointer ref to object",
35        "schema": {
36            "properties": {
37                "foo": {"type": "integer"},
38                "bar": {"$ref": "#/properties/foo"}
39            }
40        },
41        "tests": [
42            {
43                "description": "match",
44                "data": {"bar": 3},
45                "valid": true
46            },
47            {
48                "description": "mismatch",
49                "data": {"bar": true},
50                "valid": false
51            }
52        ]
53    },
54    {
55        "description": "relative pointer ref to array",
56        "schema": {
57            "items": [
58                {"type": "integer"},
59                {"$ref": "#/items/0"}
60            ]
61        },
62        "tests": [
63            {
64                "description": "match array",
65                "data": [1, 2],
66                "valid": true
67            },
68            {
69                "description": "mismatch array",
70                "data": [1, "foo"],
71                "valid": false
72            }
73        ]
74    },
75    {
76        "description": "escaped pointer ref",
77        "schema": {
78            "tilda~field": {"type": "integer"},
79            "slash/field": {"type": "integer"},
80            "percent%field": {"type": "integer"},
81            "properties": {
82                "tilda": {"$ref": "#/tilda~0field"},
83                "slash": {"$ref": "#/slash~1field"},
84                "percent": {"$ref": "#/percent%25field"}
85            }
86        },
87        "tests": [
88            {
89                "description": "slash",
90                "data": {"slash": "aoeu"},
91                "valid": false
92            },
93            {
94                "description": "tilda",
95                "data": {"tilda": "aoeu"},
96                "valid": false
97            },
98            {
99                "description": "percent",
100                "data": {"percent": "aoeu"},
101                "valid": false
102            }
103        ]
104    },
105    {
106        "description": "nested refs",
107        "schema": {
108            "definitions": {
109                "a": {"type": "integer"},
110                "b": {"$ref": "#/definitions/a"},
111                "c": {"$ref": "#/definitions/b"}
112            },
113            "$ref": "#/definitions/c"
114        },
115        "tests": [
116            {
117                "description": "nested ref valid",
118                "data": 5,
119                "valid": true
120            },
121            {
122                "description": "nested ref invalid",
123                "data": "a",
124                "valid": false
125            }
126        ]
127    },
128    {
129        "description": "remote ref, containing refs itself",
130        "schema": {"$ref": "http://highsecure.ru/ucl-schema/schema#"},
131        "tests": [
132            {
133                "description": "remote ref valid",
134                "data": {"minLength": 1},
135                "valid": true
136            },
137            {
138                "description": "remote ref invalid",
139                "data": {"minLength": -1},
140                "valid": false
141            }
142        ]
143    }
144]
145