Browse and test your LoopBack app's APIs
Go to file
Miroslav Bajtoš c9b6d451cc 1.7.2
* Allow submitting token input with empty value to remove token. (Samuel Reed)

 * Fix duplicate stylesheet issue (Pradnya Baviskar)

 * Fix explorer tests for different line endings on Windows (Pradnya Baviskar)
2015-03-30 15:19:38 +02:00
example example: use PersistedModel instead of Model 2014-10-16 10:17:47 +02:00
lib Made API doc of class use the http.path of the class if available, or the name of the class as a fallback 2015-02-17 17:23:32 +02:00
public Allow submitting token input with empty value to remove token. 2015-03-06 12:32:45 +07:00
test Fix explorer tests for different line endings on Windows 2015-02-27 15:20:10 +05:30
.gitignore gitignore: add .idea, *.tgz, *.iml 2014-10-14 08:19:12 +02:00
.jshintrc Refactoring swagger 1.2 rework. 2014-07-05 14:32:00 -05:00
CHANGES.md 1.7.2 2015-03-30 15:19:38 +02:00
CONTRIBUTING.md Fix bad CLA URL in CONTRIBUTING.md 2014-12-29 08:27:46 -08:00
LICENSE Update to dual MIT/StrongLoop license 2014-02-17 16:04:12 -08:00
README.md Add an option `uiDirs` 2014-10-24 19:24:34 +02:00
index.js Allow `uiDirs` to be defined as a String 2014-12-31 13:49:06 -08:00
package.json 1.7.2 2015-03-30 15:19:38 +02: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:

// Mount middleware before calling `explorer()` to add custom headers, auth, etc.
app.use('/explorer', loopback.basicAuth('user', 'password'));
app.use('/explorer', explorer(app, {
  basePath: '/custom-api-root',
  uiDirs: [
    path.resolve(__dirname, 'public'),
    path.resolve(__dirname, 'node_modules', 'swagger-ui')
  ]
  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());

protocol: String

Default: null

A hard override for the outgoing protocol (http or https) that is designated in Swagger resource documents. By default, loopback-explorer will write the protocol that was used to retrieve the doc. This option is useful if, for instance, your API sits behind an SSL terminator and thus needs to report its endpoints as https, even though incoming traffic is auto-detected as http.

uiDirs: Array of Strings

Sets a list of paths within your application for overriding Swagger UI files.

If present, will search uiDirs 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.