Skip to content

JsonSchema\Exception\ResourceNotFoundException #674

Closed
@msarocha

Description

@msarocha

Hi!
I use this code (inline scheme)...
`$jsonSchema = <<<'JSON'
{
"type": "object",
"properties": {
"CodigoEmpresa": { "type": "string"},
"Localidade": {"type": "string"}
}
},
"required": ["CodigoEmpresa","Localidade"],
}
JSON;

    $jsonSchemaObject = json_decode($jsonSchema);
    $schemaStorage = new SchemaStorage();
    $schemaStorage->addSchema('file://mySchema', $jsonSchemaObject);
    $jsonValidator = new Validator(new Factory($schemaStorage));

    // JSON must be decoded before it can be validated
    $jsonToValidateObject = json_decode('{"data":123}');

    // Do validation (use isValid() and getErrors() to check the result)
    $jsonValidator->validate($jsonToValidateObject, $jsonSchemaObject);
    if ($jsonValidator->isValid()) {
        echo "The supplied JSON validates against the schema.\n";
    } else {
        echo "JSON does not validate. Violations:\n";
        foreach ($jsonValidator->getErrors() as $error) {
            printf("[%s] %s\n", $error['property'], $error['message']);
        }
    }
    die();`

But i have this error...
JsonSchema\Exception\ResourceNotFoundException
file_get_contents(file://mySchema): failed to open stream: no suitable wrapper could be found

What is wrong?
thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions