Skip to content

Commit

Permalink
Part of jsonrainbow#62: support http/https schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Weiske committed Sep 10, 2013
1 parent 11ae6e2 commit d17793a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bin/validate-json
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,21 @@ if ($pathSchema === null) {
exit(6);
}
$pathSchema = $data->{'$schema'};
if ($pathSchema{0} != '/') {
if ($pathSchema{0} != '/'
&& parse_url($pathSchema, PHP_URL_SCHEME) === false
) {
$pathSchema = dirname($pathData) . '/' . $pathSchema;
}
}
if (!is_readable($pathSchema)) {

$schemaData = file_get_contents($pathSchema);
if ($schemaData === false) {
echo "Schema file '$pathSchema' is not readable.\n";
exit(2);
}

$schema = json_decode(file_get_contents($pathSchema));
$schema = json_decode($schemaData);
unset($schemaData);

if ($schema === null) {
echo "Error loading JSON schema file\n";
Expand Down

0 comments on commit d17793a

Please sign in to comment.