Browse and test your LoopBack app's APIs
Browse and test your LoopBack app's APIs.
Below is a simple LoopBack application. The explorer is mounted at
var loopback = require'loopback';var app = loopback;var explorer = require'../';var port = 3000;var Product = loopbackModelextend'product';ProductattachToloopbackmemory;appmodelProduct;appuse'/explorer' explorerapp basePath: '/api';appuse'/api' loopbackrest;console.log"Explorer mounted at localhost:" + port + "/explorer";applistenport;
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.appuse'/explorer' loopbackbasicAuth'user' 'password';appuse'/explorer' explorerappbasePath: '/custom-api-root'uiDirs:pathresolve__dirname 'public'pathresolve__dirname 'node_modules' 'swagger-ui'apiInfo:'title': 'My API''description': 'Explorer example app.'resourcePath: 'swaggerResources'version: '0.1-unreleasable';appuse'/custom-api-root' loopbackrest;
Options are passed to
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());
A hard override for the outgoing protocol (
https) that is designated in Swagger resource documents. By default,
loopback-explorerwill 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
uiDirs: Array of Strings
Sets a list of paths within your application for overriding Swagger UI files.
If present, will search
uiDirsfirst 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.
Additional information about your API. See the spec.
Sets a different path for the resource listing. You generally shouldn't have to change this.
Default: Read from package.json
Sets your API version. If not present, will read from your app's package.json.