Browse and test your LoopBack app's APIs
Go to file
Samuel Reed 34b3983b9d Remove swagger.test.js license 2014-07-10 14:09:57 -05:00
example Use express routes instead of modifying remoting. 2014-07-09 18:13:47 -05:00
lib Add url-join so path.join() doesn't break windows 2014-07-10 14:09:57 -05:00
public Restore existing styles. 2014-07-09 12:03:34 -05:00
test Remove swagger.test.js license 2014-07-10 14:09:57 -05:00
.gitignore Initial commit 2013-11-05 09:59:05 -08:00
.jshintrc Refactoring swagger 1.2 rework. 2014-07-05 14:32:00 -05:00
LICENSE Update to dual MIT/StrongLoop license 2014-02-17 16:04:12 -08:00
README.md Use express routes instead of modifying remoting. 2014-07-09 18:13:47 -05:00
index.js Remove peerDependencies, use express directly. 2014-07-10 14:09:57 -05:00
package.json Remove peerDependencies, use express directly. 2014-07-10 14:09:57 -05:00

README.md

loopback-explorer

Browse and test your LoopBack app's APIs.

Basic Usage

Below is a simple LoopBack application. The explorer is mounted at /explorer.

var loopback = require('loopback');
var app = loopback();
var explorer = require('../');
var port = 3000;

var Product = loopback.Model.extend('product');
Product.attachTo(loopback.memory());
app.model(Product);

app.use('/explorer', explorer(app, {basePath: '/api'}));
app.use('/api', loopback.rest());
console.log("Explorer mounted at localhost:" + port + "/explorer");

app.listen(port);

Advanced Usage

Many aspects of the explorer are configurable.

See options for a description of these options:

app.use('/explorer', explorer(app, {
  basePath: '/custom-api-root',
  preMiddleware: [
    // You can add as many items to this middleware chain as you like
    loopback.basicAuth(bitmex.settings.basicAuth.user, bitmex.settings.basicAuth.password)
  ],
  swaggerDistRoot: '/swagger',
  apiInfo: {
    'title': 'My API',
    'description': 'Explorer example app.'
  },
  resourcePath: 'swaggerResources',
  version: '0.1-unreleasable'
}));
app.use('/custom-api-root', loopback.rest());

Options

Options are passed to explorer(app, options).

basePath: String

Default: app.get('restAPIRoot') or '/api'.

Sets the API's base path. This must be set if you are mounting your api to a path different than '/api', e.g. with `loopback.use('/custom-api-root', loopback.rest());

swaggerDistRoot: String

Sets a path within your application for overriding Swagger UI files.

If present, will search swaggerDistRoot first when attempting to load Swagger UI, allowing you to pick and choose overrides to the interface. Use this to style your explorer or add additional functionality.

See index.html, where you may want to begin your overrides. The rest of the UI is provided by Swagger UI.

apiInfo: Object

Additional information about your API. See the spec.

resourcePath: String

Default: 'resources'

Sets a different path for the resource listing. You generally shouldn't have to change this.

version: String

Default: Read from package.json

Sets your API version. If not present, will read from your app's package.json.

preMiddleware: Array|Function

Middleware to run before any explorer routes, including static routes.

Useful for setting HTTP Auth, modifying the Host header, and so on.