Unclear validation error
One of the schemas that we use ExJsonSchema to validate has a top-level anyOf. When there's an error in this schema, we don't get helpful feedback from ExJsonSchema.validate. The error returned is: {:error, [{"Expected any of the schemata to match but none did.", "#"}]}
Here's a script that reproduces the error:
Mix.install([:ex_json_schema, :jason])
schema = """
{
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/$defs/ColumnView"
}
],
"$defs": {
"ColumnView": {
"type": "object",
"properties": {
"name": {
"description": "Column name",
"type": "string"
}
},
"required": ["name"]
}
}
}
"""
|> Jason.decode!()
ExJsonSchema.Validator.validate(schema, %{})
|> IO.inspect()
Instead it would be helpful to have details about why each of the anyOf schemas did not match.
Note: the actual schema is much larger, this is a small reproducible example of the issue
Hey, the default error formatter doesn't include a lot of detail. When you validate with ExJsonSchema.Validator.validate(schema, %{}, error_formatter: false) you get back error structs that include a lot more information and that can be handled programmatically.