Luracast / Restler-API-Explorer

Restler API Explorer is a tweaked version of Swagger UI, a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
http://luracast.com/products/restler/
94 stars 29 forks source link

localhost/resources not showing any API's #14

Open MichaelCPGordon opened 9 years ago

MichaelCPGordon commented 9 years ago

Hi there,

I'm having trouble getting the API explorer to work correctly with my restler API's.

When I go to localhost/explorer, I get the API Explorer header bar at the top of the page and below I get text saying "fetching resource list: ../resources.json" but nothing else.

When I go to localhost/resources, the page returns the following:

{
    "apiVersion": "1",
    "swaggerVersion": "1.1",
    "basePath": "http://localhost",
    "produces": [
        "application/json"
    ],
    "consumes": [
        "application/json"
    ],
    "apis": [

    ]
}

So I'm guessing that it's setting up the resources.json file but doesn't seem to acknowledge that my API's exist?

Here's my index.php file:

<?php
use Luracast\Restler\Restler;
require_once '../vendor/restler.php';

$r = new Restler();

$r->addAPIClass('Resources');
$r->addAPIClass('Employee', 'employees');

$r->addAuthenticationClass('BasicAuth');
$r->handle();

I've also tried testing this with another restler project which had a multiple API's and I have the same issue. Anything obvious that I'm missing?

WebKudu commented 9 years ago

I'm having this exact same issue. Have spent a ton of time trying to figure it out and getting nowhere. For what it's worth, Example 008 Documentation does work on my machine. Here's the contents of my index.php:

<?php // Entry point for all API requests 
require_once($_SERVER["DOCUMENT_ROOT"]."/environment/start.php");

require_once 'restler/vendor/restler.php';
use Luracast\Restler\Restler;

$restler = new Restler();

$restler->addAPIClass('ApiContact');
$restler->addAPIClass('ApiLogin');
$restler->addAPIClass('ApiRequests');
$restler->addAPIClass('ApiSubjects');
$restler->addAPIClass('Luracast\\Restler\\Resources');          // this creates resources.json at API Root

$restler->addAuthenticationClass('AccessControl');

$restler->handle(); //serve the response
WebKudu commented 9 years ago

I've resolved my problem with the line Luracast\Restler\Resources::$hideProtected = false;