Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ext/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Swagger(remotes, options, models) {

classes.forEach(function (item) {
resourceDoc.apis.push({
path: '/' + name + '/' + item.name,
path: '/' + name + item.http.path,
description: item.ctor.sharedCtor && item.ctor.sharedCtor.description
});

Expand All @@ -50,6 +50,7 @@ function Swagger(remotes, options, models) {

helper.method(api, {
path: item.name,
http: { path: item.http.path },
returns: { type: 'object', root: true }
});
function api(callback) {
Expand Down
4 changes: 3 additions & 1 deletion lib/shared-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function SharedClass(name, ctor) {
assert(ctor.sharedCtor, 'must define a sharedCtor');
this.sharedCtor = new SharedMethod(ctor.sharedCtor, 'sharedCtor');
}

this.http = util._extend({ path: '/' + this.name }, ctor.http);

assert(this.name, 'must include a remoteNamespace when creating a SharedClass');
}
Expand Down Expand Up @@ -77,4 +79,4 @@ function eachRemoteFunctionInObject(obj, f) {
f(fn, key);
}
}
}
}
22 changes: 22 additions & 0 deletions test/shared-class.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var extend = require('util')._extend;
var expect = require('chai').expect;
var SharedClass = require('../lib/shared-class');
var factory = require('./helpers/shared-objects-factory.js');

describe('SharedClass', function() {
var SomeClass;
beforeEach(function() { SomeClass = factory.createSharedClass(); });

describe('constructor', function() {
it('fills http.path from ctor.http', function() {
SomeClass.http = { path: '/foo' };
var sc = new SharedClass('some', SomeClass);
expect(sc.http.path).to.equal('/foo');
});

it('fills http.path using the name', function() {
var sc = new SharedClass('some', SomeClass);
expect(sc.http.path).to.equal('/some');
});
});
});