FriendsOfCake / crud-json-api

Build advanced JSON API Servers with almost no code.
https://crud-json-api.readthedocs.io/
MIT License
56 stars 32 forks source link

Not found error #98

Closed igreatdev closed 5 years ago

igreatdev commented 5 years ago

The problem: I trying to get resource collections, but when I do I get a not found error:

"errors": [
        {
            "status": "404",
            "title": "Not Found",
            "detail": "A route matching \"array (\n  'controller' => '',\n  'plugin' => '',\n  0 => 1,\n  '_method' => 'GET',\n  'action' => 'view',\n  'prefix' => 'api',\n  '_ext' => NULL,\n)\" could not be found."
        }
    ],

With the following debug:

"debug": {
        "class": "Cake\\Routing\\Exception\\MissingRouteException",
        "trace": [
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Routing\\Router.php",
                "line": 735,
                "function": "match",
                "class": "Cake\\Routing\\RouteCollection",
                "type": "->",
                "args": [
                    {
                        "0": 1,
                        "controller": "",
                        "plugin": "",
                        "_method": "GET",
                        "action": "view",
                        "prefix": "api",
                        "_ext": null
                    },
                    {
                        "_base": "/web-api",
                        "_port": null,
                        "_scheme": "http",
                        "_host": "localhost",
                        "params": {
                            "pass": [],
                            "controller": "Restaurants",
                            "action": "index",
                            "_method": "GET",
                            "prefix": "api",
                            "plugin": null,
                            "_matchedRoute": "/api/restaurants",
                            "_ext": null
                        }
                    }
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud-json-api\\src\\Schema\\JsonApi\\DynamicEntitySchema.php",
                "line": 301,
                "function": "url",
                "class": "Cake\\Routing\\Router",
                "type": "::",
                "args": [
                    {
                        "0": 1,
                        "controller": "",
                        "plugin": "",
                        "_method": "GET",
                        "action": "view",
                        "prefix": "api",
                        "_ext": null
                    },
                    false
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\neomerx\\json-api\\src\\Parser\\RelationshipData\\ParseRelationshipLinksTrait.php",
                "line": 117,
                "function": "getRelationshipSelfLink",
                "class": "CrudJsonApi\\Schema\\JsonApi\\DynamicEntitySchema",
                "type": "->",
                "args": [
                    {
                        "status_id": 1,
                        "location_id": 1,
                        "district_id": 1,
                        "name": "Chicken Republic",
                        "slug": "Chicken-Republic",
                        "description": "Chicken Republic at Onike, Yaba",
                        "gps_coords": null,
                        "logo_url": null,
                        "min_meal_time": 25,
                        "max_meal_time": 40,
                        "plate_fee": 0,
                        "overall_rating": null,
                        "orders_received": 0,
                        "orders_completed": 0,
                        "orders_pending": 0,
                        "min_order_total": 1,
                        "created": "2019-05-03T11:46:42+00:00",
                        "modified": "2019-05-06T21:35:23+00:00"
                    },
                    "status"
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\neomerx\\json-api\\src\\Representation\\BaseWriter.php",
                "line": 182,
                "function": "parseLinks",
                "class": "Neomerx\\JsonApi\\Parser\\IdentifierAndResource",
                "type": "->",
                "args": [
                    [],
                    {
                        "status_id": 1,
                        "location_id": 1,
                        "district_id": 1,
                        "name": "Chicken Republic",
                        "slug": "Chicken-Republic",
                        "description": "Chicken Republic at Onike, Yaba",
                        "gps_coords": null,
                        "logo_url": null,
                        "min_meal_time": 25,
                        "max_meal_time": 40,
                        "plate_fee": 0,
                        "overall_rating": null,
                        "orders_received": 0,
                        "orders_completed": 0,
                        "orders_pending": 0,
                        "min_order_total": 1,
                        "created": "2019-05-03T11:46:42+00:00",
                        "modified": "2019-05-06T21:35:23+00:00"
                    },
                    "status",
                    [],
                    true,
                    false
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\neomerx\\json-api\\src\\Representation\\DocumentWriter.php",
                "line": 209,
                "function": "getLinksRepresentation",
                "class": "Neomerx\\JsonApi\\Representation\\BaseWriter",
                "type": "->",
                "args": [
                    "",
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\neomerx\\json-api\\src\\Representation\\DocumentWriter.php",
                "line": 192,
                "function": "getRelationshipRepresentation",
                "class": "Neomerx\\JsonApi\\Representation\\DocumentWriter",
                "type": "->",
                "args": [
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\neomerx\\json-api\\src\\Representation\\DocumentWriter.php",
                "line": 277,
                "function": "getRelationshipsRepresentation",
                "class": "Neomerx\\JsonApi\\Representation\\DocumentWriter",
                "type": "->",
                "args": [
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\neomerx\\json-api\\src\\Representation\\DocumentWriter.php",
                "line": 68,
                "function": "getResourceRepresentation",
                "class": "Neomerx\\JsonApi\\Representation\\DocumentWriter",
                "type": "->",
                "args": [
                    [],
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\neomerx\\json-api\\src\\Encoder\\Encoder.php",
                "line": 197,
                "function": "addResourceToData",
                "class": "Neomerx\\JsonApi\\Representation\\DocumentWriter",
                "type": "->",
                "args": [
                    [],
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\neomerx\\json-api\\src\\Encoder\\Encoder.php",
                "line": 106,
                "function": "encodeDataToArray",
                "class": "Neomerx\\JsonApi\\Encoder\\Encoder",
                "type": "->",
                "args": [
                    [
                        {
                            "status_id": 1,
                            "location_id": 1,
                            "district_id": 1,
                            "name": "Chicken Republic",
                            "slug": "Chicken-Republic",
                            "description": "Chicken Republic at Onike, Yaba",
                            "gps_coords": null,
                            "logo_url": null,
                            "min_meal_time": 25,
                            "max_meal_time": 40,
                            "plate_fee": 0,
                            "overall_rating": null,
                            "orders_received": 0,
                            "orders_completed": 0,
                            "orders_pending": 0,
                            "min_order_total": 1,
                            "created": "2019-05-03T11:46:42+00:00",
                            "modified": "2019-05-06T21:35:23+00:00"
                        }
                    ]
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud-json-api\\src\\View\\JsonApiView.php",
                "line": 214,
                "function": "encodeData",
                "class": "Neomerx\\JsonApi\\Encoder\\Encoder",
                "type": "->",
                "args": [
                    [
                        {
                            "status_id": 1,
                            "location_id": 1,
                            "district_id": 1,
                            "name": "Chicken Republic",
                            "slug": "Chicken-Republic",
                            "description": "Chicken Republic at Onike, Yaba",
                            "gps_coords": null,
                            "logo_url": null,
                            "min_meal_time": 25,
                            "max_meal_time": 40,
                            "plate_fee": 0,
                            "overall_rating": null,
                            "orders_received": 0,
                            "orders_completed": 0,
                            "orders_pending": 0,
                            "min_order_total": 1,
                            "created": "2019-05-03T11:46:42+00:00",
                            "modified": "2019-05-06T21:35:23+00:00"
                        }
                    ]
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud-json-api\\src\\View\\JsonApiView.php",
                "line": 81,
                "function": "_encodeWithSchemas",
                "class": "CrudJsonApi\\View\\JsonApiView",
                "type": "->",
                "args": []
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Controller\\Controller.php",
                "line": 791,
                "function": "render",
                "class": "CrudJsonApi\\View\\JsonApiView",
                "type": "->",
                "args": [
                    null,
                    null
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud-json-api\\src\\Listener\\JsonApiListener.php",
                "line": 679,
                "function": "render",
                "class": "Cake\\Controller\\Controller",
                "type": "->",
                "args": []
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud-json-api\\src\\Listener\\JsonApiListener.php",
                "line": 603,
                "function": "_renderWithResources",
                "class": "CrudJsonApi\\Listener\\JsonApiListener",
                "type": "->",
                "args": [
                    {
                        "success": true,
                        "query": [
                            {
                                "id": 2,
                                "status_id": 1,
                                "location_id": 1,
                                "district_id": 1,
                                "name": "Chicken Republic",
                                "slug": "Chicken-Republic",
                                "description": "Chicken Republic at Onike, Yaba",
                                "gps_coords": null,
                                "logo_url": null,
                                "min_meal_time": 25,
                                "max_meal_time": 40,
                                "plate_fee": 0,
                                "overall_rating": null,
                                "orders_received": 0,
                                "orders_completed": 0,
                                "orders_pending": 0,
                                "min_order_total": 1,
                                "created": "2019-05-03T11:46:42+00:00",
                                "modified": "2019-05-06T21:35:23+00:00"
                            }
                        ],
                        "entities": [
                            {
                                "status_id": 1,
                                "location_id": 1,
                                "district_id": 1,
                                "name": "Chicken Republic",
                                "slug": "Chicken-Republic",
                                "description": "Chicken Republic at Onike, Yaba",
                                "gps_coords": null,
                                "logo_url": null,
                                "min_meal_time": 25,
                                "max_meal_time": 40,
                                "plate_fee": 0,
                                "overall_rating": null,
                                "orders_received": 0,
                                "orders_completed": 0,
                                "orders_pending": 0,
                                "min_order_total": 1,
                                "created": "2019-05-03T11:46:42+00:00",
                                "modified": "2019-05-06T21:35:23+00:00"
                            }
                        ]
                    }
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud\\src\\Listener\\ApiListener.php",
                "line": 129,
                "function": "render",
                "class": "CrudJsonApi\\Listener\\JsonApiListener",
                "type": "->",
                "args": [
                    {
                        "success": true,
                        "query": [
                            {
                                "id": 2,
                                "status_id": 1,
                                "location_id": 1,
                                "district_id": 1,
                                "name": "Chicken Republic",
                                "slug": "Chicken-Republic",
                                "description": "Chicken Republic at Onike, Yaba",
                                "gps_coords": null,
                                "logo_url": null,
                                "min_meal_time": 25,
                                "max_meal_time": 40,
                                "plate_fee": 0,
                                "overall_rating": null,
                                "orders_received": 0,
                                "orders_completed": 0,
                                "orders_pending": 0,
                                "min_order_total": 1,
                                "created": "2019-05-03T11:46:42+00:00",
                                "modified": "2019-05-06T21:35:23+00:00"
                            }
                        ],
                        "entities": [
                            {
                                "status_id": 1,
                                "location_id": 1,
                                "district_id": 1,
                                "name": "Chicken Republic",
                                "slug": "Chicken-Republic",
                                "description": "Chicken Republic at Onike, Yaba",
                                "gps_coords": null,
                                "logo_url": null,
                                "min_meal_time": 25,
                                "max_meal_time": 40,
                                "plate_fee": 0,
                                "overall_rating": null,
                                "orders_received": 0,
                                "orders_completed": 0,
                                "orders_pending": 0,
                                "min_order_total": 1,
                                "created": "2019-05-03T11:46:42+00:00",
                                "modified": "2019-05-06T21:35:23+00:00"
                            }
                        ]
                    }
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Event\\EventManager.php",
                "line": 353,
                "function": "respond",
                "class": "Crud\\Listener\\ApiListener",
                "type": "->",
                "args": [
                    {
                        "result": null
                    }
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Event\\EventManager.php",
                "line": 330,
                "function": "_callListener",
                "class": "Cake\\Event\\EventManager",
                "type": "->",
                "args": [
                    [
                        [],
                        "respond"
                    ],
                    {
                        "result": null
                    }
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud\\src\\Controller\\Component\\CrudComponent.php",
                "line": 540,
                "function": "dispatch",
                "class": "Cake\\Event\\EventManager",
                "type": "->",
                "args": [
                    {
                        "result": null
                    }
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud\\src\\Core\\ProxyTrait.php",
                "line": 38,
                "function": "trigger",
                "class": "Crud\\Controller\\Component\\CrudComponent",
                "type": "->",
                "args": [
                    "Crud.beforeRender",
                    {
                        "success": true,
                        "query": [
                            {
                                "id": 2,
                                "status_id": 1,
                                "location_id": 1,
                                "district_id": 1,
                                "name": "Chicken Republic",
                                "slug": "Chicken-Republic",
                                "description": "Chicken Republic at Onike, Yaba",
                                "gps_coords": null,
                                "logo_url": null,
                                "min_meal_time": 25,
                                "max_meal_time": 40,
                                "plate_fee": 0,
                                "overall_rating": null,
                                "orders_received": 0,
                                "orders_completed": 0,
                                "orders_pending": 0,
                                "min_order_total": 1,
                                "created": "2019-05-03T11:46:42+00:00",
                                "modified": "2019-05-06T21:35:23+00:00"
                            }
                        ],
                        "entities": [
                            {
                                "status_id": 1,
                                "location_id": 1,
                                "district_id": 1,
                                "name": "Chicken Republic",
                                "slug": "Chicken-Republic",
                                "description": "Chicken Republic at Onike, Yaba",
                                "gps_coords": null,
                                "logo_url": null,
                                "min_meal_time": 25,
                                "max_meal_time": 40,
                                "plate_fee": 0,
                                "overall_rating": null,
                                "orders_received": 0,
                                "orders_completed": 0,
                                "orders_pending": 0,
                                "min_order_total": 1,
                                "created": "2019-05-03T11:46:42+00:00",
                                "modified": "2019-05-06T21:35:23+00:00"
                            }
                        ]
                    }
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud\\src\\Action\\IndexAction.php",
                "line": 61,
                "function": "_trigger",
                "class": "Crud\\Core\\BaseObject",
                "type": "->",
                "args": [
                    "beforeRender",
                    {
                        "success": true,
                        "query": [
                            {
                                "id": 2,
                                "status_id": 1,
                                "location_id": 1,
                                "district_id": 1,
                                "name": "Chicken Republic",
                                "slug": "Chicken-Republic",
                                "description": "Chicken Republic at Onike, Yaba",
                                "gps_coords": null,
                                "logo_url": null,
                                "min_meal_time": 25,
                                "max_meal_time": 40,
                                "plate_fee": 0,
                                "overall_rating": null,
                                "orders_received": 0,
                                "orders_completed": 0,
                                "orders_pending": 0,
                                "min_order_total": 1,
                                "created": "2019-05-03T11:46:42+00:00",
                                "modified": "2019-05-06T21:35:23+00:00"
                            }
                        ],
                        "entities": [
                            {
                                "status_id": 1,
                                "location_id": 1,
                                "district_id": 1,
                                "name": "Chicken Republic",
                                "slug": "Chicken-Republic",
                                "description": "Chicken Republic at Onike, Yaba",
                                "gps_coords": null,
                                "logo_url": null,
                                "min_meal_time": 25,
                                "max_meal_time": 40,
                                "plate_fee": 0,
                                "overall_rating": null,
                                "orders_received": 0,
                                "orders_completed": 0,
                                "orders_pending": 0,
                                "min_order_total": 1,
                                "created": "2019-05-03T11:46:42+00:00",
                                "modified": "2019-05-06T21:35:23+00:00"
                            }
                        ]
                    }
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud\\src\\Action\\BaseAction.php",
                "line": 71,
                "function": "call_user_func_array",
                "args": [
                    [
                        [],
                        "_handle"
                    ],
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud\\src\\Controller\\Component\\CrudComponent.php",
                "line": 244,
                "function": "handle",
                "class": "Crud\\Action\\BaseAction",
                "type": "->",
                "args": [
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\friendsofcake\\crud\\src\\Controller\\ControllerTrait.php",
                "line": 68,
                "function": "execute",
                "class": "Crud\\Controller\\Component\\CrudComponent",
                "type": "->",
                "args": []
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\ActionDispatcher.php",
                "line": 120,
                "function": "invokeAction",
                "class": "App\\Controller\\Api\\AppController",
                "type": "->",
                "args": []
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\ActionDispatcher.php",
                "line": 94,
                "function": "_invoke",
                "class": "Cake\\Http\\ActionDispatcher",
                "type": "->",
                "args": [
                    {
                        "paginate": {
                            "page": 1,
                            "limit": 10,
                            "maxLimit": 100
                        },
                        "helpers": [],
                        "request": {
                            "trustProxy": false
                        },
                        "response": [],
                        "components": [],
                        "View": {
                            "passedArgs": [],
                            "hasRendered": false,
                            "uuids": [],
                            "viewClass": null,
                            "viewVars": {
                                "_meta": {
                                    "record_count": 1,
                                    "page_count": 1,
                                    "page_limit": null
                                },
                                "_links": {
                                    "self": [],
                                    "first": [],
                                    "last": []
                                },
                                "_withJsonApiVersion": false,
                                "_absoluteLinks": false,
                                "_jsonApiBelongsToLinks": false,
                                "_jsonOptions": [],
                                "_debugPrettyPrint": true,
                                "_repositories": {
                                    "Restaurants": []
                                },
                                "_include": [],
                                "_fieldSets": [],
                                "restaurants": [
                                    {
                                        "status_id": 1,
                                        "location_id": 1,
                                        "district_id": 1,
                                        "name": "Chicken Republic",
                                        "slug": "Chicken-Republic",
                                        "description": "Chicken Republic at Onike, Yaba",
                                        "gps_coords": null,
                                        "logo_url": null,
                                        "min_meal_time": 25,
                                        "max_meal_time": 40,
                                        "plate_fee": 0,
                                        "overall_rating": null,
                                        "orders_received": 0,
                                        "orders_completed": 0,
                                        "orders_pending": 0,
                                        "min_order_total": 1,
                                        "created": "2019-05-03T11:46:42+00:00",
                                        "modified": "2019-05-06T21:35:23+00:00"
                                    }
                                ],
                                "_serialize": true,
                                "_inflect": "dasherize",
                                "queryLog": {
                                    "default": [
                                        {
                                            "query": "SHOW FULL COLUMNS FROM `restaurants`",
                                            "took": 69,
                                            "params": [],
                                            "numRows": 19,
                                            "error": null
                                        },
                                        {
                                            "query": "SHOW INDEXES FROM `restaurants`",
                                            "took": 2,
                                            "params": [],
                                            "numRows": 5,
                                            "error": null
                                        },
                                        {
                                            "query": "SELECT * FROM information_schema.key_column_usage AS kcu\n            INNER JOIN information_schema.referential_constraints AS rc\n            ON (\n                kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME\n                AND kcu.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA\n            )\n            WHERE kcu.TABLE_SCHEMA = 'foodappng' AND kcu.TABLE_NAME = 'restaurants' AND rc.TABLE_NAME = 'restaurants'",
                                            "took": 87,
                                            "params": {
                                                "1": "foodappng",
                                                "2": "restaurants",
                                                "3": "restaurants"
                                            },
                                            "numRows": 0,
                                            "error": null
                                        },
                                        {
                                            "query": "SHOW TABLE STATUS WHERE Name = 'restaurants'",
                                            "took": 74,
                                            "params": {
                                                "1": "restaurants"
                                            },
                                            "numRows": 1,
                                            "error": null
                                        },
                                        {
                                            "query": "SELECT Restaurants.id AS `Restaurants__id`, Restaurants.status_id AS `Restaurants__status_id`, Restaurants.location_id AS `Restaurants__location_id`, Restaurants.district_id AS `Restaurants__district_id`, Restaurants.name AS `Restaurants__name`, Restaurants.slug AS `Restaurants__slug`, Restaurants.description AS `Restaurants__description`, Restaurants.gps_coords AS `Restaurants__gps_coords`, Restaurants.logo_url AS `Restaurants__logo_url`, Restaurants.min_meal_time AS `Restaurants__min_meal_time`, Restaurants.max_meal_time AS `Restaurants__max_meal_time`, Restaurants.plate_fee AS `Restaurants__plate_fee`, Restaurants.overall_rating AS `Restaurants__overall_rating`, Restaurants.orders_received AS `Restaurants__orders_received`, Restaurants.orders_completed AS `Restaurants__orders_completed`, Restaurants.orders_pending AS `Restaurants__orders_pending`, Restaurants.min_order_total AS `Restaurants__min_order_total`, Restaurants.created AS `Restaurants__created`, Restaurants.modified AS `Restaurants__modified` FROM restaurants Restaurants LIMIT 10 OFFSET 0",
                                            "took": 2,
                                            "params": [],
                                            "numRows": 1,
                                            "error": null
                                        },
                                        {
                                            "query": "SELECT (COUNT(*)) AS `count` FROM restaurants Restaurants",
                                            "took": 1,
                                            "params": [],
                                            "numRows": 1,
                                            "error": null
                                        }
                                    ],
                                    "test": [],
                                    "debug_kit": []
                                },
                                "_pagination": {
                                    "self": "/web-api/api/restaurants?page=1",
                                    "first": "/web-api/api/restaurants?page=1",
                                    "last": "/web-api/api/restaurants?page=1",
                                    "prev": null,
                                    "next": null,
                                    "record_count": 1,
                                    "page_count": 1,
                                    "page_limit": null
                                },
                                "viewVar": "restaurants",
                                "success": true
                            }
                        },
                        "passedArgs": [],
                        "modelClass": "Restaurants",
                        "viewClass": null,
                        "viewVars": {
                            "_withJsonApiVersion": false,
                            "_meta": [],
                            "_links": [],
                            "_absoluteLinks": false,
                            "_jsonApiBelongsToLinks": false,
                            "_jsonOptions": [],
                            "_debugPrettyPrint": true,
                            "_repositories": {
                                "Restaurants": []
                            },
                            "_include": [],
                            "_fieldSets": [],
                            "restaurants": [
                                {
                                    "status_id": 1,
                                    "location_id": 1,
                                    "district_id": 1,
                                    "name": "Chicken Republic",
                                    "slug": "Chicken-Republic",
                                    "description": "Chicken Republic at Onike, Yaba",
                                    "gps_coords": null,
                                    "logo_url": null,
                                    "min_meal_time": 25,
                                    "max_meal_time": 40,
                                    "plate_fee": 0,
                                    "overall_rating": null,
                                    "orders_received": 0,
                                    "orders_completed": 0,
                                    "orders_pending": 0,
                                    "min_order_total": 1,
                                    "created": "2019-05-03T11:46:42+00:00",
                                    "modified": "2019-05-06T21:35:23+00:00"
                                }
                            ],
                            "_serialize": true,
                            "_inflect": "dasherize",
                            "queryLog": {
                                "default": [
                                    {
                                        "query": "SHOW FULL COLUMNS FROM `restaurants`",
                                        "took": 69,
                                        "params": [],
                                        "numRows": 19,
                                        "error": null
                                    },
                                    {
                                        "query": "SHOW INDEXES FROM `restaurants`",
                                        "took": 2,
                                        "params": [],
                                        "numRows": 5,
                                        "error": null
                                    },
                                    {
                                        "query": "SELECT * FROM information_schema.key_column_usage AS kcu\n            INNER JOIN information_schema.referential_constraints AS rc\n            ON (\n                kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME\n                AND kcu.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA\n            )\n            WHERE kcu.TABLE_SCHEMA = 'foodappng' AND kcu.TABLE_NAME = 'restaurants' AND rc.TABLE_NAME = 'restaurants'",
                                        "took": 87,
                                        "params": {
                                            "1": "foodappng",
                                            "2": "restaurants",
                                            "3": "restaurants"
                                        },
                                        "numRows": 0,
                                        "error": null
                                    },
                                    {
                                        "query": "SHOW TABLE STATUS WHERE Name = 'restaurants'",
                                        "took": 74,
                                        "params": {
                                            "1": "restaurants"
                                        },
                                        "numRows": 1,
                                        "error": null
                                    },
                                    {
                                        "query": "SELECT Restaurants.id AS `Restaurants__id`, Restaurants.status_id AS `Restaurants__status_id`, Restaurants.location_id AS `Restaurants__location_id`, Restaurants.district_id AS `Restaurants__district_id`, Restaurants.name AS `Restaurants__name`, Restaurants.slug AS `Restaurants__slug`, Restaurants.description AS `Restaurants__description`, Restaurants.gps_coords AS `Restaurants__gps_coords`, Restaurants.logo_url AS `Restaurants__logo_url`, Restaurants.min_meal_time AS `Restaurants__min_meal_time`, Restaurants.max_meal_time AS `Restaurants__max_meal_time`, Restaurants.plate_fee AS `Restaurants__plate_fee`, Restaurants.overall_rating AS `Restaurants__overall_rating`, Restaurants.orders_received AS `Restaurants__orders_received`, Restaurants.orders_completed AS `Restaurants__orders_completed`, Restaurants.orders_pending AS `Restaurants__orders_pending`, Restaurants.min_order_total AS `Restaurants__min_order_total`, Restaurants.created AS `Restaurants__created`, Restaurants.modified AS `Restaurants__modified` FROM restaurants Restaurants LIMIT 10 OFFSET 0",
                                        "took": 2,
                                        "params": [],
                                        "numRows": 1,
                                        "error": null
                                    },
                                    {
                                        "query": "SELECT (COUNT(*)) AS `count` FROM restaurants Restaurants",
                                        "took": 1,
                                        "params": [],
                                        "numRows": 1,
                                        "error": null
                                    }
                                ],
                                "test": [],
                                "debug_kit": []
                            },
                            "_pagination": {
                                "self": "/web-api/api/restaurants?page=1",
                                "first": "/web-api/api/restaurants?page=1",
                                "last": "/web-api/api/restaurants?page=1",
                                "prev": null,
                                "next": null,
                                "record_count": 1,
                                "page_count": 1,
                                "page_limit": null
                            },
                            "viewVar": "restaurants",
                            "success": true
                        },
                        "dispatchComponents": {
                            "Crud": true
                        },
                        "RequestHandler": {
                            "enabled": true,
                            "ext": null,
                            "ajaxLayout": null,
                            "request": {
                                "trustProxy": false
                            },
                            "response": [],
                            "components": []
                        },
                        "Crud": {
                            "request": {
                                "trustProxy": false
                            },
                            "response": [],
                            "components": []
                        },
                        "Restaurants": [],
                        "Paginator": {
                            "request": {
                                "trustProxy": false
                            },
                            "response": [],
                            "components": []
                        }
                    }
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\BaseApplication.php",
                "line": 235,
                "function": "dispatch",
                "class": "Cake\\Http\\ActionDispatcher",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\Runner.php",
                "line": 65,
                "function": "__invoke",
                "class": "Cake\\Http\\BaseApplication",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    [],
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Routing\\Middleware\\RoutingMiddleware.php",
                "line": 162,
                "function": "__invoke",
                "class": "Cake\\Http\\Runner",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\Runner.php",
                "line": 65,
                "function": "__invoke",
                "class": "Cake\\Routing\\Middleware\\RoutingMiddleware",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    [],
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Routing\\Middleware\\AssetMiddleware.php",
                "line": 88,
                "function": "__invoke",
                "class": "Cake\\Http\\Runner",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\Runner.php",
                "line": 65,
                "function": "__invoke",
                "class": "Cake\\Routing\\Middleware\\AssetMiddleware",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    [],
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Error\\Middleware\\ErrorHandlerMiddleware.php",
                "line": 96,
                "function": "__invoke",
                "class": "Cake\\Http\\Runner",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\Runner.php",
                "line": 65,
                "function": "__invoke",
                "class": "Cake\\Error\\Middleware\\ErrorHandlerMiddleware",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    [],
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\debug_kit\\src\\Middleware\\DebugKitMiddleware.php",
                "line": 53,
                "function": "__invoke",
                "class": "Cake\\Http\\Runner",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\Runner.php",
                "line": 65,
                "function": "__invoke",
                "class": "DebugKit\\Middleware\\DebugKitMiddleware",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    [],
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\Runner.php",
                "line": 51,
                "function": "__invoke",
                "class": "Cake\\Http\\Runner",
                "type": "->",
                "args": [
                    {
                        "trustProxy": false
                    },
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\vendor\\cakephp\\cakephp\\src\\Http\\Server.php",
                "line": 98,
                "function": "run",
                "class": "Cake\\Http\\Runner",
                "type": "->",
                "args": [
                    [],
                    {
                        "trustProxy": false
                    },
                    []
                ]
            },
            {
                "file": "C:\\wamp\\www\\web-api\\webroot\\index.php",
                "line": 40,
                "function": "run",
                "class": "Cake\\Http\\Server",
                "type": "->",
                "args": []
            }
        ]
    },
    "query": {
        "default": [
            {
                "query": "SHOW FULL COLUMNS FROM `restaurants`",
                "took": 69,
                "params": [],
                "numRows": 19,
                "error": null
            },
            {
                "query": "SHOW INDEXES FROM `restaurants`",
                "took": 2,
                "params": [],
                "numRows": 5,
                "error": null
            },
            {
                "query": "SELECT * FROM information_schema.key_column_usage AS kcu\n            INNER JOIN information_schema.referential_constraints AS rc\n            ON (\n                kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME\n                AND kcu.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA\n            )\n            WHERE kcu.TABLE_SCHEMA = 'foodappng' AND kcu.TABLE_NAME = 'restaurants' AND rc.TABLE_NAME = 'restaurants'",
                "took": 87,
                "params": {
                    "1": "foodappng",
                    "2": "restaurants",
                    "3": "restaurants"
                },
                "numRows": 0,
                "error": null
            },
            {
                "query": "SHOW TABLE STATUS WHERE Name = 'restaurants'",
                "took": 74,
                "params": {
                    "1": "restaurants"
                },
                "numRows": 1,
                "error": null
            },
            {
                "query": "SELECT Restaurants.id AS `Restaurants__id`, Restaurants.status_id AS `Restaurants__status_id`, Restaurants.location_id AS `Restaurants__location_id`, Restaurants.district_id AS `Restaurants__district_id`, Restaurants.name AS `Restaurants__name`, Restaurants.slug AS `Restaurants__slug`, Restaurants.description AS `Restaurants__description`, Restaurants.gps_coords AS `Restaurants__gps_coords`, Restaurants.logo_url AS `Restaurants__logo_url`, Restaurants.min_meal_time AS `Restaurants__min_meal_time`, Restaurants.max_meal_time AS `Restaurants__max_meal_time`, Restaurants.plate_fee AS `Restaurants__plate_fee`, Restaurants.overall_rating AS `Restaurants__overall_rating`, Restaurants.orders_received AS `Restaurants__orders_received`, Restaurants.orders_completed AS `Restaurants__orders_completed`, Restaurants.orders_pending AS `Restaurants__orders_pending`, Restaurants.min_order_total AS `Restaurants__min_order_total`, Restaurants.created AS `Restaurants__created`, Restaurants.modified AS `Restaurants__modified` FROM restaurants Restaurants LIMIT 10 OFFSET 0",
                "took": 2,
                "params": [],
                "numRows": 1,
                "error": null
            },
            {
                "query": "SELECT (COUNT(*)) AS `count` FROM restaurants Restaurants",
                "took": 1,
                "params": [],
                "numRows": 1,
                "error": null
            }
        ],
        "test": [],
        "debug_kit": []
    }

Here is my route:

const API_RESOURCES = [
  'Restaurants',
];

Router::prefix('api', function (RouteBuilder $routes) {
    // No $routes->applyMiddleware() here.
    // Connect API actions here.

    $routes->setExtensions(['json']);

    foreach (API_RESOURCES as $apiResource) {
        $routes->resources($apiResource, [
          'inflect' => 'dasherize'
        ]);
    }

    $routes->fallbacks(DashedRoute::class);
});

Url trying to access: http://localhost/web-api/api/restaurants

Directory setup: image

AppController:

<?php
/**
 * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 * @link      https://cakephp.org CakePHP(tm) Project
 * @since     0.2.9
 * @license   https://opensource.org/licenses/mit-license.php MIT License
 */
namespace App\Controller\Api;

use Cake\Controller\Controller;
use Cake\Event\Event;

/**
 * Application Controller
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @link https://book.cakephp.org/3.0/en/controllers.html#the-app-controller
 */
class AppController extends Controller
{
    use \Crud\Controller\ControllerTrait;

    /**
     * Initialization hook method.
     *
     * Use this method to add common initialization code like loading components.
     *
     * e.g. `$this->loadComponent('Security');`
     *
     * @return void
     */
    public function initialize()
    {
        parent::initialize();

        $this->loadComponent('RequestHandler', [
            // 'enableBeforeRedirect' => false,
        ]);
        $this->loadComponent('Crud.Crud', [
              'actions' => [
                'Crud.Index',
                'Crud.View'
            ],
            'listeners' => ['CrudJsonApi.JsonApi','CrudJsonApi.Pagination','Crud.ApiQueryLog']
        ]);
        // $this->loadComponent('Flash');

        /*
         * Enable the following component for recommended CakePHP security settings.
         * see https://book.cakephp.org/3.0/en/controllers/components/security.html
         */
        //$this->loadComponent('Security');
    }
}

RestaurantController:

<?php

namespace App\Controller\Api;

use App\Controller\Api\AppController;

/**
 * 
 */
Class RestaurantsController extends AppController 
{
    /**
        @SWG\Swagger(
            @SWG\Info(
                title="Restaurants",
                description="Quickstart Resturants",
                termsOfService="http://swagger.io/terms/",
                version="1.0.0"
            )
        )

        @SWG\Get(
            path="/restaurants",
            summary="Retrieve a list of resturants",
            tags={"restaurant"},
            consumes={"application/json"},
            produces={"application/json"},
            @SWG\Parameter(
                name="sort",
                description="Sort results by field",
                in="query",
                required=false,
                type="string",
                enum={"name", "description"}
            ),
            @SWG\Response(
                response="200",
                description="Successful operation",
                @SWG\Schema(
                    type="object",
                    ref="#/definitions/Cocktail"
                )
            ),
            @SWG\Response(
                response=429,
                description="Rate Limit Exceeded"
            )
        )

        @SWG\Definition(
            definition="Cocktail",
            required={"name", "description"},
            @SWG\Property(
                property="id",
                type="integer",
                description="CakePHP record id"
            ),
            @SWG\Property(
                property="name",
                type="string",
                description="CakePHP name field"
            ),
            @SWG\Property(
                property="description",
                type="string",
                description="Description of a most tasty cocktail"
            )
        )
    */

    public $paginate = [
        'page' => 1,
        'limit' => 10,
        'maxLimit' => 100,
        // 'fields' => [
        //     'id', 'name', 'description'
        // ],
        // 'sortWhitelist' => [
        //     'id', 'name', 'description'
        // ]
    ];

}
bravo-kernel commented 5 years ago

This is a bug tracker and not a help forum. Please turn to Slack or IRC for help.

Also make sure to check https://crud-json-api.readthedocs.io/en/latest/additional-information/common-issues.html