Skip to content

Commit

Permalink
Fix segmentation error during validation reporting in metaschema
Browse files Browse the repository at this point in the history
See: #182
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Oct 28, 2024
1 parent a120944 commit 812903e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/command_metaschema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ auto sourcemeta::jsonschema::cli::metaschema(
cache.insert({dialect.value(), metaschema_template});
}

sourcemeta::blaze::ErrorTraceOutput output{metaschema};
sourcemeta::blaze::ErrorTraceOutput output{entry.second};
if (sourcemeta::blaze::evaluate(cache.at(dialect.value()), entry.second,
std::ref(output))) {
log_verbose(options)
Expand Down
4 changes: 2 additions & 2 deletions test/metaschema/fail_directory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ test "$CODE" = "1" || exit 1
cat << EOF > "$TMP/expected.txt"
fail: $(realpath "$TMP")/schemas/schema_2.json
error: Schema validation failure
The string value "object" was expected to equal one of the following values: "array", "boolean", "integer", "null", "number", "object", and "string"
The integer value 1 was expected to equal one of the following values: "array", "boolean", "integer", "null", "number", "object", and "string"
at instance location "/type"
at evaluate path "/properties/type/anyOf/0/\$ref/enum"
The value was expected to consist of an array of at least 1 item
at instance location "/type"
at evaluate path "/properties/type/anyOf/1/type"
The string value was expected to validate against at least one of the 2 given subschemas
The integer value was expected to validate against at least one of the 2 given subschemas
at instance location "/type"
at evaluate path "/properties/type/anyOf"
The object value was expected to validate against the 33 defined properties subschemas
Expand Down
4 changes: 2 additions & 2 deletions test/metaschema/fail_single.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ test "$CODE" = "1" || exit 1
cat << EOF > "$TMP/expected.txt"
fail: $(realpath "$TMP")/schema.json
error: Schema validation failure
The string value "object" was expected to equal one of the following values: "array", "boolean", "integer", "null", "number", "object", and "string"
The integer value 1 was expected to equal one of the following values: "array", "boolean", "integer", "null", "number", "object", and "string"
at instance location "/type"
at evaluate path "/properties/type/anyOf/0/\$ref/enum"
The value was expected to consist of an array of at least 1 item
at instance location "/type"
at evaluate path "/properties/type/anyOf/1/type"
The string value was expected to validate against at least one of the 2 given subschemas
The integer value was expected to validate against at least one of the 2 given subschemas
at instance location "/type"
at evaluate path "/properties/type/anyOf"
The object value was expected to validate against the 33 defined properties subschemas
Expand Down
7 changes: 6 additions & 1 deletion test/metaschema/pass_2020_12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ trap clean EXIT
cat << 'EOF' > "$TMP/schema.json"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string"
"type": "string",
"$defs": {
"foo": {
"type": [ "string", "null" ]
}
}
}
EOF

Expand Down

0 comments on commit 812903e

Please sign in to comment.