Merge pull request #58 from strongloop/godaddy-improvements-1
Godaddy improvements - round 1
This commit is contained in:
commit
72f36b56bf
|
@ -43,7 +43,8 @@ var classHelper = module.exports = {
|
|||
generateResourceDocAPIEntry: function(aClass) {
|
||||
return {
|
||||
path: aClass.http.path,
|
||||
description: aClass.ctor.sharedCtor && aClass.ctor.sharedCtor.description
|
||||
description: aClass.ctor.settings.description ||
|
||||
aClass.ctor.sharedCtor && aClass.ctor.sharedCtor.description
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -137,8 +137,9 @@ var routeHelper = module.exports = {
|
|||
parameters: accepts,
|
||||
// TODO(schoon) - We don't have descriptions for this yet.
|
||||
responseMessages: [],
|
||||
summary: route.description, // TODO(schoon) - Excerpt?
|
||||
notes: '' // TODO(schoon) - `description` metadata?
|
||||
summary: route.description,
|
||||
notes: route.notes,
|
||||
deprecated: route.deprecated
|
||||
})]
|
||||
};
|
||||
|
||||
|
|
|
@ -28,8 +28,17 @@ function Swagger(loopbackApplication, swaggerApp, opts) {
|
|||
basePath: loopbackApplication.get('restApiRoot') || '/api',
|
||||
resourcePath: 'resources',
|
||||
// Default consumes/produces
|
||||
consumes: ['application/json', 'application/x-www-form-urlencoded'],
|
||||
produces: ['application/json'],
|
||||
consumes: [
|
||||
'application/json',
|
||||
'application/x-www-form-urlencoded',
|
||||
'application/xml', 'text/xml'
|
||||
],
|
||||
produces: [
|
||||
'application/json',
|
||||
'application/xml', 'text/xml',
|
||||
// JSONP content types
|
||||
'application/javascript', 'text/javascript'
|
||||
],
|
||||
version: getVersion()
|
||||
});
|
||||
|
||||
|
@ -147,7 +156,7 @@ function getVersion() {
|
|||
try {
|
||||
version = require(path.join(process.cwd(), 'package.json')).version;
|
||||
} catch(e) {
|
||||
version = '';
|
||||
version = '1.0.0';
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
|
|
@ -75,6 +75,19 @@ describe('route-helper', function() {
|
|||
expect(opDoc.format).to.equal('byte');
|
||||
});
|
||||
|
||||
it('includes `notes` metadata', function() {
|
||||
var doc = createAPIDoc({
|
||||
notes: 'some notes'
|
||||
});
|
||||
expect(doc.operations[0].notes).to.equal('some notes');
|
||||
});
|
||||
|
||||
it('includes `deprecated` metadata', function() {
|
||||
var doc = createAPIDoc({
|
||||
deprecated: 'true'
|
||||
});
|
||||
expect(doc.operations[0].deprecated).to.equal('true');
|
||||
});
|
||||
});
|
||||
|
||||
// Easy wrapper around createRoute
|
||||
|
|
|
@ -104,6 +104,33 @@ describe('swagger definition', function() {
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('includes `consumes`', function(done) {
|
||||
var app = mountSwagger();
|
||||
getAPIDeclaration(app, 'products').end(function(err, res) {
|
||||
if (err) return done(err);
|
||||
expect(res.body.consumes).to.have.members([
|
||||
'application/json',
|
||||
'application/x-www-form-urlencoded',
|
||||
'application/xml', 'text/xml'
|
||||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('includes `produces`', function(done) {
|
||||
var app = mountSwagger();
|
||||
getAPIDeclaration(app, 'products').end(function(err, res) {
|
||||
if (err) return done(err);
|
||||
expect(res.body.produces).to.have.members([
|
||||
'application/json',
|
||||
'application/xml', 'text/xml',
|
||||
// JSONP content types
|
||||
'application/javascript', 'text/javascript'
|
||||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Cross-origin resource sharing', function() {
|
||||
|
|
Loading…
Reference in New Issue