-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline references broken #301
Comments
@thewilkybarkid I'll try to explain how it works now. Before we had to invoke <?php
$schemaStorage = new SchemaStorage;
$schemaStorage->addSchema('file://schemaId', $schema);
$validator = new Validator(Validator::CHECK_MODE_NORMAL, $schemaStorage); You should do it because all local references get converted into remote ones (its done by |
I was tring to use $schemaStorage = new \JsonSchema\SchemaStorage;
$schemaStorage->addSchema($schema_filepath, json_encode(file_get_contents($schema_filepath)));
$validator = new \JsonSchema\Validator(\JsonSchema\Validator::CHECK_MODE_NORMAL, $schemaStorage); but it leads to error: I also tried to use $schemaStorage = new \JsonSchema\SchemaStorage;
$factory = new \JsonSchema\Constraints\Factory($schemaStorage);
$schemaStorage->addSchema($schema_filepath, json_encode(file_get_contents($schema_filepath)));
$validator = new \JsonSchema\Validator(\JsonSchema\Constraints\Constraint::CHECK_MODE_NORMAL, $factory); but there's still the same error. I'm not sure what's the proper way to do it. |
@jgao1 The error is telling you exactly what you're doing wrong. The You want to do something like this: $schemaStorage = new \JsonSchema\SchemaStorage;
$factory = new \JsonSchema\Constraints\Factory($schemaStorage);
$schemaStorage->addSchema($schema_filepath, json_encode(file_get_contents($schema_filepath)));
$validator = new \JsonSchema\Validator($factory); |
@shmax Thanks for your reply! I tried your suggested way but still got the same $jsonValidator->check($jsonToValidateObject, $jsonSchemaObject); to $jsonValidator->check($jsonToValidateObject, (object)['$ref' => 'file://mySchema']); Without doing this, although "$jsonSchemaObject is mutated to normalize the references (to file://mySchema#/definitions/integerData, etc)" after |
Resolved by #326 |
When passing a schema object, rather than a reference to a schema as the README now suggests, #277 now causes inline references to break.
Failing test case:
causes:
The text was updated successfully, but these errors were encountered: