Skip to content

Commit

Permalink
Support JSON Schema Draft 7 in test and validate (#72)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti authored Jun 11, 2024
1 parent d2f7310 commit fe81f10
Show file tree
Hide file tree
Showing 149 changed files with 424 additions and 15,538 deletions.
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4
noa https://github.com/sourcemeta/noa 5ff4024902642afc9cc2f9a9e02ae9dff9d15d4f
jsontoolkit https://github.com/sourcemeta/jsontoolkit 0f31b9576a2eb442c64b4005c9ae4b03dbbc7834
jsontoolkit https://github.com/sourcemeta/jsontoolkit 573808a8e7f615a05d1afeaae83dade50eeac920
hydra https://github.com/sourcemeta/hydra 3c53d3fdef79e9ba603d48470a508cc45472a0dc
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ schemas**, both during local development and when running on CI/CD pipelines.
>
> **Current Limitations:**
>
> - The `validate` and `test` commands only support JSON Schema Draft 4 and Draft 6
> - The `validate` and `test` commands only support JSON Schema Draft 4, Draft 6, and Draft 7
> - It is not possible to collect annotations with the `validate` command
What our users are saying
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ add_jsonschema_test_unix(validate_pass_draft4)
add_jsonschema_test_unix(validate_fail_draft4)
add_jsonschema_test_unix(validate_pass_draft6)
add_jsonschema_test_unix(validate_fail_draft6)
add_jsonschema_test_unix(validate_pass_draft7)
add_jsonschema_test_unix(validate_fail_draft7)
add_jsonschema_test_unix(validate_fail_remote_no_http)
add_jsonschema_test_unix(validate_non_supported)
add_jsonschema_test_unix(validate_pass_with_metaschema)
Expand Down
4 changes: 2 additions & 2 deletions test/lint_fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trap clean EXIT

cat << 'EOF' > "$TMP/schema.json"
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-06/schema#",
"type": "string",
"enum": [ "foo" ]
}
Expand All @@ -19,7 +19,7 @@ EOF

cat << 'EOF' > "$TMP/expected.json"
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-06/schema#",
"const": "foo"
}
EOF
Expand Down
34 changes: 34 additions & 0 deletions test/validate_fail_draft7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

set -o errexit
set -o nounset

TMP="$(mktemp -d)"
clean() { rm -rf "$TMP"; }
trap clean EXIT

cat << 'EOF' > "$TMP/schema.json"
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
EOF

cat << 'EOF' > "$TMP/instance.json"
{ "foo": 1 }
EOF

"$1" validate "$TMP/schema.json" "$TMP/instance.json" && CODE="$?" || CODE="$?"

if [ "$CODE" = "0" ]
then
echo "FAIL" 1>&2
exit 1
else
echo "PASS" 1>&2
fi
25 changes: 25 additions & 0 deletions test/validate_pass_draft7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

set -o errexit
set -o nounset

TMP="$(mktemp -d)"
clean() { rm -rf "$TMP"; }
trap clean EXIT

cat << 'EOF' > "$TMP/schema.json"
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"foo": {
"type": "string"
}
}
}
EOF

cat << 'EOF' > "$TMP/instance.json"
{ "foo": "bar" }
EOF

"$1" validate "$TMP/schema.json" "$TMP/instance.json"
1 change: 0 additions & 1 deletion vendor/jsontoolkit/CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions vendor/jsontoolkit/Config.uk

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions vendor/jsontoolkit/Makefile.uk

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions vendor/jsontoolkit/src/json/CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions vendor/jsontoolkit/src/jsonl/CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions vendor/jsontoolkit/src/jsonpointer/CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions vendor/jsontoolkit/src/jsonschema/CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion vendor/jsontoolkit/src/jsonschema/compile_describe.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 29 additions & 4 deletions vendor/jsontoolkit/src/jsonschema/compile_evaluate.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/jsontoolkit/src/jsonschema/compile_json.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fe81f10

Please sign in to comment.