fix resource listing and remove id from each property

This commit is contained in:
Ying Tang 2015-04-05 16:51:15 -07:00
parent b9df4b6706
commit e22b826bca
2 changed files with 10 additions and 5 deletions

View File

@ -81,10 +81,6 @@ var modelHelper = module.exports = {
required.push(key); required.push(key);
} }
if (prop.hasOwnProperty('required')){
delete prop.required;
}
// Change mismatched keys. // Change mismatched keys.
prop = translateDataTypeKeys(prop); prop = translateDataTypeKeys(prop);
@ -93,6 +89,9 @@ var modelHelper = module.exports = {
delete prop.type; delete prop.type;
} }
delete prop.required;
delete prop.id;
// Assign this back to the properties object. // Assign this back to the properties object.
properties[key] = prop; properties[key] = prop;

View File

@ -12,6 +12,7 @@ var urlJoin = require('./url-join');
var _defaults = require('lodash.defaults'); var _defaults = require('lodash.defaults');
var classHelper = require('./class-helper'); var classHelper = require('./class-helper');
var routeHelper = require('./route-helper'); var routeHelper = require('./route-helper');
var _cloneDeep = require('lodash.clonedeep');
/** /**
* Create a remotable Swagger module for plugging into `RemoteObjects`. * Create a remotable Swagger module for plugging into `RemoteObjects`.
@ -129,11 +130,16 @@ function addRoute(app, uri, doc, opts) {
* @return {Object} Resource doc. * @return {Object} Resource doc.
*/ */
function generateResourceDoc(opts) { function generateResourceDoc(opts) {
var apiInfo = _cloneDeep(opts.apiInfo);
for (var property in apiInfo) {
property = Array.isArray(property) ? property.join('') : property;
}
return { return {
swaggerVersion: opts.swaggerVersion, swaggerVersion: opts.swaggerVersion,
apiVersion: opts.version, apiVersion: opts.version,
// See https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#513-info-object // See https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#513-info-object
info: opts.apiInfo, info: apiInfo,
// TODO Authorizations // TODO Authorizations
// https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#514-authorizations-object // https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#514-authorizations-object
consumes: ['application/json', 'application/xml', 'text/xml'], consumes: ['application/json', 'application/xml', 'text/xml'],