-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Description
https://github.com/swaggest/php-json-schema/releases/tag/v0.12.7 broke file resolve process
Test data
schemas
- example_item.json
- stats.json
- index.php
stats.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "urn:example:api:response-example",
"type": "object",
"additionalProperties": false,
"required": [
"confirmed",
"to_pay"
],
"definitions": {
"example_item": {
"$ref": "example_item.json"
}
},
"properties": {
"confirmed": {
"$ref": "example_item.json"
},
"to_pay": {
"$ref": "example_item.json"
}
}
}
example_item.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "urn:example:api:example_item",
"type": "object",
"additionalProperties": false,
"required": ["_type", "count"],
"properties": {
"_type": {
"$id": "#/definitions/example_item/properties/confirmed/properties/_type",
"type": "string",
"enum": ["example_item"]
},
"count": {
"$id": "#/definitions/example_item/properties/confirmed/properties/count",
"type": "integer"
}
}
}
index.php
<?php
require(__DIR__ . '/vendor/autoload.php');
$file = __DIR__ . "/schemas/stats.json";
use Swaggest\JsonSchema\Schema;
var_dump("File exists: " . is_file($file));
try {
$schema = Schema::import($file);
$schema->in((object)[]);
} catch (Exception $e) {
// Normal: Required property missing: confirmed, data: [] at #->$ref[/mnt/Dev/xxxyyyzzz/testbench/schemas/stats.json]
// Fails: file_get_contents(example_item.json): failed to open stream: No such file or directory in /mnt/Dev/xxxyyyzzz/testbench/vendor/swaggest/json-schema/src/RemoteRef/BasicFetcher.php on line 11
// Err: Object, boolean expected, null received at #->$ref:/mnt/Dev/xxxyyyzzz/testbench/schemas/stats.json->properties:definitions->additionalProperties:example_item->$ref:example_item.json at #->$ref:/mnt/Dev/xxxyyyzzz/testbench/schemas/stats.json->properties:definitions->additionalProperties:example_item
echo PHP_EOL . "------------------" . PHP_EOL;
print_r($e->getMessage());
echo PHP_EOL . "------------------" . PHP_EOL;
}
See #66
Introduced by #69
Metadata
Metadata
Assignees
Labels
No labels