Validator::validate() doesn't correctly apply schema ID when the schema is an assoc array (works when an object) #767
Open
Description
Update: this is due to the validator not applying the schema ID correctly, it only handles an object, not an assoc array.
I have this schema:
{
"id": "tests/schemas/suggest/empty.schema.json",
"allOf": [
{
"$ref": "baseline.schema.json"
}
],
"properties": {
"items": {
"maxItems": 0
}
}
}
With the update to 6.x, this fails with
file_get_contents(internal://provided-schema/tests/schemas/suggest/baseline.schema.json): Failed to open stream: No such file or directory (JsonSchema\Exception\ResourceNotFoundException)
I guess the schemaless ref is now interpreted as internal in some way?
If I modify my schema as so
{
"id": "tests/schemas/suggest/empty.schema.json",
"allOf": [
{
"$ref": "file://tests/schemas/suggest/baseline.schema.json"
}
],
"properties": {
"items": {
"maxItems": 0
}
}
}
Now it says
file_get_contents(file://tests/schemas/suggest/baseline.schema.json): Failed to open stream: no suitable wrapper could be found (JsonSchema\Exception\ResourceNotFoundException)
which means it understands it needs to read the file locally. For some reason, it doesn't read the file even though it exists.
If I add
$uri = substr($uri, 7);
to strip file://
before here, it works.
Should this happen conditionally, if there's a file://
prefix, strip it? There's some file://
special handling a little later in the function, but it's already too late because an error was raised.