Example #1
0
 /**
  * Parses and resolves the json schema source and returns the object
  * presentation of the schema
  *
  * @param string $source
  * @return string
  */
 public function parse($source)
 {
     $resolver = new RefResolver();
     $parser = new JsonSchema(null, $resolver);
     $schema = $parser->parse($source);
     if (!$schema->getDefinition() instanceof ComplexType) {
         throw new RuntimeException('Schema must be an object');
     }
     return serialize($schema);
 }
Example #2
0
    protected static function getTestInserts()
    {
        $schemaSource = <<<'JSON'
{
    "id": "http://phpsx.org#",
    "title": "test",
    "type": "object",
    "properties": {
        "totalResults": {
            "type": "integer"
        },
        "itemsPerPage": {
            "type": "integer"
        },
        "startIndex": {
            "type": "integer"
        },
        "entry": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "title": {
                        "type": "string"
                    },
                    "content": {
                        "type": "string"
                    },
                    "date": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            }
        }
    }
}
JSON;
        $parser = new JsonSchema();
        $schema = $parser->parse($schemaSource);
        return ['fusio_user' => [['status' => 0, 'name' => 'Consumer', 'email' => '*****@*****.**', 'password' => '$2y$10$8EZyVlUy.oNrF8NcDxY7OeTBt6.3fikdH82JlfeRhqSlXitxJMdB6', 'date' => '2015-02-27 19:59:15'], ['status' => 2, 'name' => 'Disabled', 'email' => '*****@*****.**', 'password' => '$2y$10$8EZyVlUy.oNrF8NcDxY7OeTBt6.3fikdH82JlfeRhqSlXitxJMdB6', 'date' => '2015-02-27 19:59:15'], ['status' => 1, 'name' => 'Developer', 'email' => '*****@*****.**', 'password' => '$2y$10$8EZyVlUy.oNrF8NcDxY7OeTBt6.3fikdH82JlfeRhqSlXitxJMdB6', 'date' => '2015-02-27 19:59:15'], ['status' => 3, 'name' => 'Deleted', 'email' => '*****@*****.**', 'password' => '$2y$10$8EZyVlUy.oNrF8NcDxY7OeTBt6.3fikdH82JlfeRhqSlXitxJMdB6', 'date' => '2015-02-27 19:59:15']], 'fusio_action' => [['status' => 1, 'name' => 'Util-Static-Response', 'class' => 'Fusio\\Adapter\\Util\\Action\\UtilStaticResponse', 'config' => serialize(['response' => '{"foo": "bar"}']), 'date' => '2015-02-27 19:59:15'], ['status' => 1, 'name' => 'Sql-Table', 'class' => 'Fusio\\Adapter\\Sql\\Action\\SqlTable', 'config' => serialize(['connection' => 1, 'table' => 'app_news']), 'date' => '2015-02-27 19:59:15']], 'fusio_app' => [['userId' => 2, 'status' => 1, 'name' => 'Foo-App', 'url' => 'http://google.com', 'parameters' => '', 'appKey' => '5347307d-d801-4075-9aaa-a21a29a448c5', 'appSecret' => '342cefac55939b31cd0a26733f9a4f061c0829ed87dae7caff50feaa55aff23d', 'date' => '2015-02-22 22:19:07'], ['userId' => 2, 'status' => 2, 'name' => 'Pending', 'url' => 'http://google.com', 'parameters' => '', 'appKey' => '7c14809c-544b-43bd-9002-23e1c2de6067', 'appSecret' => 'bb0574181eb4a1326374779fe33e90e2c427f28ab0fc1ffd168bfd5309ee7caa', 'date' => '2015-02-22 22:19:07'], ['userId' => 2, 'status' => 3, 'name' => 'Deactivated', 'url' => 'http://google.com', 'parameters' => '', 'appKey' => 'f46af464-f7eb-4d04-8661-13063a30826b', 'appSecret' => '17b882987298831a3af9c852f9cd0219d349ba61fcf3fc655ac0f07eece951f9', 'date' => '2015-02-22 22:19:07']], 'fusio_app_code' => [['appId' => 3, 'userId' => 3, 'code' => 'GHMbtJi0ZuAUnp80', 'redirectUri' => '', 'scope' => 'authorization', 'date' => date('Y-m-d H:i:s')]], 'fusio_connection' => [['name' => 'Native', 'class' => 'Fusio\\Impl\\Tests\\Connection\\Native', 'config' => '']], 'fusio_routes' => [['status' => 1, 'methods' => 'GET|POST|PUT|DELETE', 'path' => '/foo', 'controller' => 'Fusio\\Impl\\Controller\\SchemaApiController']], 'fusio_rate' => [['status' => 1, 'priority' => 5, 'name' => 'silver', 'rateLimit' => 8, 'timespan' => 'P1M']], 'fusio_rate_allocation' => [['rateId' => 3, 'routeId' => 61]], 'fusio_routes_method' => [['routeId' => 61, 'method' => 'GET', 'version' => 1, 'status' => Resource::STATUS_DEVELOPMENT, 'active' => 1, 'public' => 1, 'request' => null, 'response' => 2, 'action' => 3], ['routeId' => 61, 'method' => 'POST', 'version' => 1, 'status' => Resource::STATUS_DEVELOPMENT, 'active' => 1, 'public' => 0, 'request' => 1, 'response' => 1, 'action' => 3], ['routeId' => 61, 'method' => 'PUT', 'version' => 1, 'status' => Resource::STATUS_DEVELOPMENT, 'active' => 0, 'public' => 0, 'request' => null, 'response' => null, 'action' => null], ['routeId' => 61, 'method' => 'DELETE', 'version' => 1, 'status' => Resource::STATUS_DEVELOPMENT, 'active' => 0, 'public' => 0, 'request' => null, 'response' => null, 'action' => null]], 'fusio_routes_action' => [['routeId' => 61, 'actionId' => 3]], 'fusio_routes_schema' => [['routeId' => 61, 'schemaId' => 2], ['routeId' => 61, 'schemaId' => 1]], 'fusio_log' => [['appId' => 3, 'routeId' => 1, 'ip' => '127.0.0.1', 'userAgent' => 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36', 'method' => 'GET', 'path' => '/bar', 'header' => 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'body' => 'foobar', 'date' => date('Y-m-d 00:00:00')], ['appId' => 3, 'routeId' => 1, 'ip' => '127.0.0.1', 'userAgent' => 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36', 'method' => 'GET', 'path' => '/bar', 'header' => 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'body' => 'foobar', 'date' => date('Y-m-d 00:00:00')]], 'fusio_log_error' => [['logId' => 1, 'message' => 'Syntax error, malformed JSON', 'trace' => '[trace]', 'file' => '[file]', 'line' => 74]], 'fusio_schema' => [['status' => 1, 'name' => 'Foo-Schema', 'source' => $schemaSource, 'cache' => serialize($schema)]], 'fusio_scope' => [['name' => 'foo', 'description' => 'Foo access'], ['name' => 'bar', 'description' => 'Bar access']], 'fusio_app_scope' => [['appId' => 3, 'scopeId' => 3], ['appId' => 3, 'scopeId' => 4], ['appId' => 3, 'scopeId' => 5]], 'fusio_app_token' => [['appId' => 1, 'userId' => 1, 'status' => 1, 'token' => 'da250526d583edabca8ac2f99e37ee39aa02a3c076c0edc6929095e20ca18dcf', 'scope' => 'backend,authorization', 'ip' => '127.0.0.1', 'date' => '2015-06-25 22:49:09'], ['appId' => 2, 'userId' => 1, 'status' => 1, 'token' => 'b8f6f61bd22b440a3e4be2b7491066682bfcde611dbefa1b15d2e7f6522d77e2', 'scope' => 'consumer,authorization', 'ip' => '127.0.0.1', 'date' => '2015-06-25 22:49:09'], ['appId' => 3, 'userId' => 2, 'status' => 1, 'token' => 'b41344388feed85bc362e518387fdc8c81b896bfe5e794131e1469770571d873', 'scope' => 'bar', 'ip' => '127.0.0.1', 'date' => '2015-06-25 22:49:09'], ['appId' => 1, 'userId' => 4, 'status' => 1, 'token' => 'e4a4d21e8ca88b215572b4d8635c492d8877fd8d3de6b98ba7c08d282adfb94f', 'scope' => 'backend', 'ip' => '127.0.0.1', 'date' => '2015-06-25 22:49:09'], ['appId' => 2, 'userId' => 2, 'status' => 1, 'token' => '1b8fca875fc81c78538d541b3ed0557a34e33feaf71c2ecdc2b9ebd40aade51b', 'scope' => 'consumer', 'ip' => '127.0.0.1', 'date' => '2015-06-25 22:49:09']], 'fusio_scope_routes' => [['scopeId' => 5, 'routeId' => 60, 'allow' => 1, 'methods' => 'GET|POST|PUT|DELETE'], ['scopeId' => 5, 'routeId' => 61, 'allow' => 1, 'methods' => 'GET|POST|PUT|DELETE']], 'fusio_user_scope' => [['userId' => 1, 'scopeId' => 4], ['userId' => 1, 'scopeId' => 5], ['userId' => 2, 'scopeId' => 2], ['userId' => 2, 'scopeId' => 3], ['userId' => 2, 'scopeId' => 4], ['userId' => 2, 'scopeId' => 5], ['userId' => 3, 'scopeId' => 3], ['userId' => 4, 'scopeId' => 1], ['userId' => 4, 'scopeId' => 2], ['userId' => 4, 'scopeId' => 3]], 'fusio_user_grant' => [['userId' => 1, 'appId' => 1, 'allow' => 1, 'date' => '2015-02-27 19:59:15']], 'app_news' => [['id' => 1, 'title' => 'foo', 'content' => 'bar', 'date' => '2015-02-27 19:59:15'], ['id' => 2, 'title' => 'bar', 'content' => 'foo', 'date' => '2015-02-27 19:59:15']]];
    }