コード例 #1
0
		},
		"nestedSchema": {
			"id": "/test-schema/foo",
			"nested": {
				"id": "#bar"
			}
		},
		"testSchemaFoo": {
			"id": "/test-schema-foo"
		},
		"somewhereElse": {
			"id": "http://somewhere-else.com/test-schema"
		}
	}
}');
$store->add($url, $schema);
if (!recursiveEqual($store->get($url . "#foo"), $schema->properties->foo)) {
    throw new Exception("#foo not found");
}
if (!recursiveEqual($store->get($url . "?baz=1"), $schema->properties->baz)) {
    throw new Exception("?baz=1 not found");
}
if (!recursiveEqual($store->get($url . "/foobar"), $schema->properties->foobar)) {
    throw new Exception("/foobar not found");
}
if (!recursiveEqual($store->get($url . "/foo#bar"), $schema->properties->nestedSchema->nested)) {
    throw new Exception("/foo#bar not found");
}
if ($store->get($urlBase . "bar")) {
    throw new Exception("/bar should not be indexed, as it should not be trusted");
}
コード例 #2
0
// Add internal $ref, and make sure it's resolved
$url = $urlBase . "test-schema";
$schema = json_decode('{
	"title": "Test schema",
	"properties": {
		"foo": {
			"$ref": "#/definitions/foo"
		}
	},
	"definitions": {
		"foo": {
			"title": "foo"
		}
	}
}');
$store->add($url, $schema);
$schema = $store->get($url);
if ($schema->properties->foo != $schema->definitions->foo) {
    throw new Exception('$ref was not resolved');
}
// Add external $ref, and don't resolve it
// While we're at it, use an array, not an object
$schema = array("title" => "Test schema 2", "properties" => array("foo" => array('$ref' => "somewhere-else")));
$store->add($urlBase . "test-schema-2", $schema);
$schema = $store->get($urlBase . "test-schema-2");
if (!$schema->properties->foo->{'$ref'}) {
    throw new Exception('$ref should still exist');
}
if (!recursiveEqual($store->missing(), array($urlBase . "somewhere-else"))) {
    throw new Exception('$store->missing() is not correct: ' . json_encode($store->missing()) . ' is not ' . json_encode(array($urlBase . "somewhere-else")));
}
コード例 #3
0
ファイル: Killua_Jsv4.php プロジェクト: Vaizard/Glued
    public function schematest2($request, $response)
    {
        $store = new SchemaStore();
        $urlBase = "http://example.com/";
        // Add external $ref, and don't resolve it
        // While we're at it, use an array, not an object
        $schema = array("title" => "Test schema 2", "properties" => array("foo" => array('$ref' => "somewhere-else")));
        $otherSchema = json_decode('{
	"title": "Somewhere else",
	"item": {
        "huuu": { "type": "string" }
    }
}');
        echo '<br /><div>zakladni</div>';
        var_dump($schema);
        $store->add($urlBase . "test-schema-2", $schema);
        $store->add($urlBase . "somewhere-else", $otherSchema);
        $schema = $store->get($urlBase . "test-schema-2");
        echo '<br /><div>finale</div>';
        var_dump($schema);
        /*
        echo '<br /><div>chybi</div>';
        var_dump($store->missing());
        echo '<br /><div>mezikrok</div>';
        var_dump($schema);
        $store->add($urlBase . "somewhere-else", $otherSchema);
        $schema	 = $store->get($urlBase . "test-schema-2");
        */
    }
コード例 #4
0
<?php

use Jsv4\SchemaStore;
$store = new SchemaStore();
$url = "http://example.com/test-schema";
$schema = json_decode('{
	"title": "Test schema"
}');
$store->add($url, $schema);
if (!recursiveEqual($store->get($url), $schema)) {
    throw new Exception("Not equal");
}
if (!recursiveEqual($store->get($url . "#/title"), $schema->title)) {
    throw new Exception("Not equal");
}