Merge pull request #117 from hacksparrow/feature/register-self

Register loopback-explorer to app
This commit is contained in:
Miroslav Bajtoš 2015-08-31 10:58:43 +02:00
commit e75d8bb353
2 changed files with 13 additions and 2 deletions

View File

@ -21,8 +21,9 @@ explorer.routes = routes;
*/
function explorer(loopbackApplication, options) {
var mountPath = options.mountPath || '/explorer';
loopbackApplication.use(mountPath, routes(loopbackApplication, options));
options = _defaults({}, options, { mountPath: '/explorer' });
loopbackApplication.use(options.mountPath, routes(loopbackApplication, options));
loopbackApplication.set('loopback-explorer', options);
}
function routes(loopbackApplication, options) {

View File

@ -12,6 +12,11 @@ describe('explorer', function() {
describe('with default config', function() {
beforeEach(givenLoopBackAppWithExplorer());
it('should register "loopback-explorer" to the app', function() {
expect(this.app.get('loopback-explorer'))
.to.have.property('mountPath', '/explorer');
});
it('should redirect to /explorer/', function(done) {
request(this.app)
.get('/explorer')
@ -50,6 +55,11 @@ describe('explorer', function() {
describe('with custom explorer base', function() {
beforeEach(givenLoopBackAppWithExplorer('/swagger'));
it('should register "loopback-explorer" to the app', function() {
expect(this.app.get('loopback-explorer'))
.to.have.property('mountPath', '/swagger');
});
it('should serve correct swagger-ui config', function(done) {
request(this.app)
.get('/swagger/config.json')