Merge pull request #86 from geoand/fix/resourcePath
Made API doc of class use the http.path of the class if available
This commit is contained in:
commit
5e60df025a
|
@ -23,11 +23,16 @@ var classHelper = module.exports = {
|
||||||
* @return {Object} API Declaration.
|
* @return {Object} API Declaration.
|
||||||
*/
|
*/
|
||||||
generateAPIDoc: function(aClass, opts) {
|
generateAPIDoc: function(aClass, opts) {
|
||||||
|
var resourcePath = urlJoin('/', aClass.name);
|
||||||
|
if(aClass.http && aClass.http.path) {
|
||||||
|
resourcePath = aClass.http.path;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
apiVersion: opts.version,
|
apiVersion: opts.version,
|
||||||
swaggerVersion: opts.swaggerVersion,
|
swaggerVersion: opts.swaggerVersion,
|
||||||
basePath: opts.basePath,
|
basePath: opts.basePath,
|
||||||
resourcePath: urlJoin('/', opts.resourcePath),
|
resourcePath: urlJoin('/', resourcePath),
|
||||||
apis: [],
|
apis: [],
|
||||||
consumes: aClass.http.consumes || opts.consumes,
|
consumes: aClass.http.consumes || opts.consumes,
|
||||||
produces: aClass.http.produces || opts.produces,
|
produces: aClass.http.produces || opts.produces,
|
||||||
|
|
|
@ -12,12 +12,32 @@ describe('class-helper', function() {
|
||||||
|
|
||||||
expect(doc.description).to.equal('line1\nline2');
|
expect(doc.description).to.equal('line1\nline2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('sets resourcePath from aClass.http.path', function() {
|
||||||
|
var doc = generateAPIDoc({}, 'otherPath');
|
||||||
|
|
||||||
|
expect(doc.resourcePath).to.equal('/otherPath');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sets resourcePath from aClass.name', function() {
|
||||||
|
var doc = generateAPIDoc({});
|
||||||
|
|
||||||
|
expect(doc.resourcePath).to.equal('/test');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Easy wrapper around createRoute
|
// Easy wrapper around createRoute
|
||||||
function generateResourceDocAPIEntry(def) {
|
function generateResourceDocAPIEntry(def) {
|
||||||
return classHelper.generateResourceDocAPIEntry(_defaults(def, {
|
return classHelper.generateResourceDocAPIEntry(_defaults(def, {
|
||||||
http: { path: '/test' },
|
http: { path: '/test' },
|
||||||
ctor: { settings: { } },
|
ctor: { settings: { } }
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateAPIDoc(def, httpPath) {
|
||||||
|
return classHelper.generateAPIDoc(_defaults(def, {
|
||||||
|
http: { path: httpPath || null },
|
||||||
|
name: 'test',
|
||||||
|
ctor: { settings: { } }
|
||||||
|
}), {resourcePath: 'resources'});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue