Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
core https://github.com/sourcemeta/core ed4b82bd917e75041962358c5e9461ea5b2aa37e
core https://github.com/sourcemeta/core 5d187a796444fef1b5e044c659800085a4be7ef4
jsonbinpack https://github.com/sourcemeta/jsonbinpack 40293a182cabf15678ca0b59cddaf108e7862787
blaze https://github.com/sourcemeta/blaze 9c1bae4dc45b9f04585c4520021bc8298cda2f51
blaze https://github.com/sourcemeta/blaze 47ecf3c751d9e0e101e99567fa1d778d56e42432
mbedtls https://github.com/Mbed-TLS/mbedtls v3.6.6
curl https://github.com/curl/curl curl-8_20_0
nghttp2 https://github.com/nghttp2/nghttp2 v1.67.1
Expand Down
8 changes: 4 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ add_jsonschema_test_unix(validate/fail_schema_enoent)
add_jsonschema_test_unix(validate/fail_schema_invalid_json)
add_jsonschema_test_unix(validate/fail_schema_non_schema)
add_jsonschema_test_unix(validate/fail_schema_unknown_dialect)
add_jsonschema_test_unix(validate/fail_2020_12_format_assertion)
add_jsonschema_test_unix(validate/pass_2020_12_format_assertion)
add_jsonschema_test_unix(validate/pass_2020_12_format_assertion_optional)
add_jsonschema_test_unix(validate/fail_resolve_unknown_dialect)
add_jsonschema_test_unix(validate/fail_resolve_invalid_id)
Expand Down Expand Up @@ -380,7 +380,7 @@ add_jsonschema_test_unix(test/fail_false_single_resolve_verbose)
add_jsonschema_test_unix(test/fail_multi_test)
add_jsonschema_test_unix(test/fail_multi_resolve)
add_jsonschema_test_unix(test/fail_multi_resolve_verbose)
add_jsonschema_test_unix(test/fail_format_assertion)
add_jsonschema_test_unix(test/pass_format_assertion)
add_jsonschema_test_unix(test/fail_unresolvable)
add_jsonschema_test_unix(test/fail_unresolvable_fragment)
add_jsonschema_test_unix(test/fail_unresolvable_anchor)
Expand Down Expand Up @@ -558,7 +558,7 @@ add_jsonschema_test_unix(compile/pass_default_dialect_config_relative)
add_jsonschema_test_unix(compile/pass_yaml)
add_jsonschema_test_unix(compile/fail_no_schema)
add_jsonschema_test_unix(compile/fail_schema_invalid_json)
add_jsonschema_test_unix(compile/fail_format_assertion)
add_jsonschema_test_unix(compile/pass_format_assertion)
add_jsonschema_test_unix(compile/fail_unknown_metaschema)
add_jsonschema_test_unix(compile/fail_default_dialect_config_extension_mismatch)
add_jsonschema_test_unix(compile/pass_resolve_remap)
Expand Down Expand Up @@ -656,7 +656,7 @@ add_jsonschema_test_unix(lint/fail_lint_disable_one)
add_jsonschema_test_unix(lint/fail_lint_disable_one_verbose)
add_jsonschema_test_unix(lint/fail_lint_disable_unknown_verbose)
add_jsonschema_test_unix(lint/fail_lint_disable_many)
add_jsonschema_test_unix(lint/fail_lint_format_assertion)
add_jsonschema_test_unix(lint/pass_lint_format_assertion)
add_jsonschema_test_unix(lint/fail_lint_examples)
add_jsonschema_test_unix(lint/fail_lint_default)
add_jsonschema_test_unix(lint/pass_lint_json)
Expand Down
57 changes: 0 additions & 57 deletions test/compile/fail_format_assertion.sh

This file was deleted.

86 changes: 86 additions & 0 deletions test/compile/pass_format_assertion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/sh

set -o errexit
set -o nounset

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

cat << 'EOF' > "$TMP/metaschema.json"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/custom-metaschema",
"$vocabulary": {
"https://json-schema.org/draft/2020-12/vocab/core": true,
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
"https://json-schema.org/draft/2020-12/vocab/validation": true,
"https://json-schema.org/draft/2020-12/vocab/format-assertion": true
}
}
EOF

cat << 'EOF' > "$TMP/schema.json"
{
"$schema": "https://example.com/custom-metaschema",
"type": "string",
"format": "email"
}
EOF

"$1" compile "$TMP/schema.json" \
--resolve "$TMP/metaschema.json" > "$TMP/template.json" 2> "$TMP/stderr.txt"

cat << EOF > "$TMP/expected_stderr.txt"
EOF

diff "$TMP/stderr.txt" "$TMP/expected_stderr.txt"

cat << EOF > "$TMP/expected.json"
[
5,
false,
true,
[
[
[
40,
[ "format" ],
[],
"file://$(realpath "$TMP")/schema.json#/format",
1,
[ 14, 5 ]
],
[
96,
[],
[],
"file://$(realpath "$TMP")/schema.json#/format",
1,
[ 8, 4 ],
[
[
50,
[ "format" ],
[],
"file://$(realpath "$TMP")/schema.json#/format",
1,
[ 1, "email" ]
]
]
],
[
11,
[ "type" ],
[],
"file://$(realpath "$TMP")/schema.json#/type",
1,
[ 8, 4 ]
]
]
],
[]
]
EOF

diff "$TMP/template.json" "$TMP/expected.json"
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,18 @@ EOF
cat << 'EOF' > "$TMP/schema.json"
{
"$schema": "https://example.com/custom-metaschema",
"title": "Email",
"description": "An email address",
"type": "string",
"examples": [ "hello" ]
"format": "email",
"examples": [ "foo@bar.com" ]
}
EOF

"$1" lint "$TMP/schema.json" \
--resolve "$TMP/metaschema.json" 2> "$TMP/stderr.txt" \
&& EXIT_CODE="$?" || EXIT_CODE="$?"
test "$EXIT_CODE" = "4"
--resolve "$TMP/metaschema.json" > "$TMP/stderr.txt" 2>&1

cat << EOF > "$TMP/expected.txt"
error: Cannot compile unsupported vocabulary
at file path $(realpath "$TMP")/schema.json
at uri https://json-schema.org/draft/2020-12/vocab/format-assertion
EOF

diff "$TMP/stderr.txt" "$TMP/expected.txt"

"$1" lint "$TMP/schema.json" \
--resolve "$TMP/metaschema.json" --json > "$TMP/stdout.txt" \
&& EXIT_CODE="$?" || EXIT_CODE="$?"
test "$EXIT_CODE" = "4"

cat << EOF > "$TMP/expected.txt"
{
"error": "Cannot compile unsupported vocabulary",
"filePath": "$(realpath "$TMP")/schema.json",
"uri": "https://json-schema.org/draft/2020-12/vocab/format-assertion"
}
EOF

diff "$TMP/stdout.txt" "$TMP/expected.txt"
8 changes: 7 additions & 1 deletion test/lint/pass_lint_list_exclude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,15 @@ oneof_to_anyof_disjoint_types
orphan_definitions
Schema definitions in `$defs` or `definitions` that are never internally referenced can be removed

pattern_non_ecma_regex
For interoperability reasons, only set this keyword to a regular expression that strictly adheres to the ECMA-262 dialect

pattern_properties_default
Setting the `patternProperties` keyword to the empty object does not add any further constraint

pattern_properties_non_ecma_regex
For interoperability reasons, only set the keys of this keyword to regular expressions that strictly adhere to the ECMA-262 dialect

portable_anchor_names
Keep anchors within the safe allowed character set across JSON Schema dialects (`^[A-Za-z][A-Za-z0-9_.-]*$`)

Expand Down Expand Up @@ -307,7 +313,7 @@ unsatisfiable_max_contains
unsatisfiable_min_properties
Setting `minProperties` to a number less than `required` does not add any further constraint

Number of rules: 99
Number of rules: 101
EOF

diff "$TMP/output.txt" "$TMP/expected.txt"
8 changes: 7 additions & 1 deletion test/lint/pass_lint_list_long.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,15 @@ oneof_to_anyof_disjoint_types
orphan_definitions
Schema definitions in `$defs` or `definitions` that are never internally referenced can be removed

pattern_non_ecma_regex
For interoperability reasons, only set this keyword to a regular expression that strictly adheres to the ECMA-262 dialect

pattern_properties_default
Setting the `patternProperties` keyword to the empty object does not add any further constraint

pattern_properties_non_ecma_regex
For interoperability reasons, only set the keys of this keyword to regular expressions that strictly adhere to the ECMA-262 dialect

portable_anchor_names
Keep anchors within the safe allowed character set across JSON Schema dialects (`^[A-Za-z][A-Za-z0-9_.-]*$`)

Expand Down Expand Up @@ -313,7 +319,7 @@ valid_default
valid_examples
Only include instances in the `examples` array that validate against the schema

Number of rules: 101
Number of rules: 103
EOF

diff "$TMP/output.txt" "$TMP/expected.txt"
8 changes: 7 additions & 1 deletion test/lint/pass_lint_list_short.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,15 @@ oneof_to_anyof_disjoint_types
orphan_definitions
Schema definitions in `$defs` or `definitions` that are never internally referenced can be removed

pattern_non_ecma_regex
For interoperability reasons, only set this keyword to a regular expression that strictly adheres to the ECMA-262 dialect

pattern_properties_default
Setting the `patternProperties` keyword to the empty object does not add any further constraint

pattern_properties_non_ecma_regex
For interoperability reasons, only set the keys of this keyword to regular expressions that strictly adhere to the ECMA-262 dialect

portable_anchor_names
Keep anchors within the safe allowed character set across JSON Schema dialects (`^[A-Za-z][A-Za-z0-9_.-]*$`)

Expand Down Expand Up @@ -313,7 +319,7 @@ valid_default
valid_examples
Only include instances in the `examples` array that validate against the schema

Number of rules: 101
Number of rules: 103
EOF

diff "$TMP/output.txt" "$TMP/expected.txt"
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,22 @@ cat << 'EOF' > "$TMP/test.json"
"description": "A valid instance",
"valid": true,
"data": "foo@bar.com"
},
{
"description": "An invalid instance",
"valid": false,
"data": "not-an-email"
}
]
}
EOF

"$1" test "$TMP/test.json" \
--resolve "$TMP/metaschema.json" --resolve "$TMP/schema.json" \
1> "$TMP/output.txt" 2>&1 \
&& EXIT_CODE="$?" || EXIT_CODE="$?"
test "$EXIT_CODE" = "4"
> "$TMP/output.txt" 2>&1

cat << EOF > "$TMP/expected.txt"
$(realpath "$TMP")/test.json:
error: Cannot compile unsupported vocabulary
at file path $(realpath "$TMP")/test.json
at uri https://json-schema.org/draft/2020-12/vocab/format-assertion
$(realpath "$TMP")/test.json: PASS 2/2
EOF

diff "$TMP/output.txt" "$TMP/expected.txt"

"$1" test "$TMP/test.json" \
--resolve "$TMP/metaschema.json" --resolve "$TMP/schema.json" \
--json > "$TMP/stdout.txt" \
&& EXIT_CODE="$?" || EXIT_CODE="$?"
test "$EXIT_CODE" = "4"

cat << EOF > "$TMP/expected.txt"
{
"error": "Cannot compile unsupported vocabulary",
"filePath": "$(realpath "$TMP")/test.json",
"uri": "https://json-schema.org/draft/2020-12/vocab/format-assertion"
}
EOF

diff "$TMP/stdout.txt" "$TMP/expected.txt"
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,18 @@ cat << 'EOF' > "$TMP/schema.json"
EOF

cat << 'EOF' > "$TMP/instance.json"
{ "email": "not-an-email" }
{ "email": "foo@bar.com" }
EOF

"$1" validate "$TMP/schema.json" "$TMP/instance.json" \
--resolve "$TMP/metaschema.json" 2> "$TMP/stderr.txt" \
&& EXIT_CODE="$?" || EXIT_CODE="$?"
test "$EXIT_CODE" = "4"
--resolve "$TMP/metaschema.json" --verbose 2> "$TMP/stderr.txt"

cat << EOF > "$TMP/expected.txt"
error: Cannot compile unsupported vocabulary
at file path $(realpath "$TMP")/schema.json
at uri https://json-schema.org/draft/2020-12/vocab/format-assertion
ok: $(realpath "$TMP")/instance.json
matches $(realpath "$TMP")/schema.json
annotation: "email"
at instance location "" (line 1, column 1)
at evaluate path "/properties"
EOF

diff "$TMP/stderr.txt" "$TMP/expected.txt"

"$1" validate "$TMP/schema.json" "$TMP/instance.json" \
--resolve "$TMP/metaschema.json" --json > "$TMP/stdout.txt" \
&& EXIT_CODE="$?" || EXIT_CODE="$?"
test "$EXIT_CODE" = "4"

cat << EOF > "$TMP/expected.txt"
{
"error": "Cannot compile unsupported vocabulary",
"filePath": "$(realpath "$TMP")/schema.json",
"uri": "https://json-schema.org/draft/2020-12/vocab/format-assertion"
}
EOF

diff "$TMP/stdout.txt" "$TMP/expected.txt"
Loading
Loading