-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
32 lines (27 loc) · 819 Bytes
/
Copy pathexample.py
File metadata and controls
32 lines (27 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
from jsonpath_schema import Schema, validateJSONPath
def main() -> int:
schema: Schema = {
"type": "object",
"properties": {
"users": {
"type": "array",
"items": {"$ref": "https://example.org/user"},
}
},
}
schemastore: dict[str, Schema] = {
"https://example.org/user": {
"type": "object",
"properties": {"name": {"type": "string"}},
}
}
paths = ["$.users[0].name", "$.users[0].unknown"]
error_count = 0
for path in paths:
if not validateJSONPath(path, schema, schemastore, strict=True):
print(path, "is not valid JSONPath in schema")
error_count += 1
return error_count
if __name__ == "__main__":
sys.exit(main())