diff --git a/lib/model-helper.js b/lib/model-helper.js index 2e8e5fe..ec1fea7 100644 --- a/lib/model-helper.js +++ b/lib/model-helper.js @@ -81,10 +81,6 @@ var modelHelper = module.exports = { required.push(key); } - if (prop.hasOwnProperty('required')){ - delete prop.required; - } - // Change mismatched keys. prop = translateDataTypeKeys(prop); @@ -93,6 +89,9 @@ var modelHelper = module.exports = { delete prop.type; } + delete prop.required; + delete prop.id; + // Assign this back to the properties object. properties[key] = prop; diff --git a/lib/swagger.js b/lib/swagger.js index 16ffec1..83afe11 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -12,6 +12,7 @@ var urlJoin = require('./url-join'); var _defaults = require('lodash.defaults'); var classHelper = require('./class-helper'); var routeHelper = require('./route-helper'); +var _cloneDeep = require('lodash.clonedeep'); /** * Create a remotable Swagger module for plugging into `RemoteObjects`. @@ -129,11 +130,16 @@ function addRoute(app, uri, doc, opts) { * @return {Object} Resource doc. */ function generateResourceDoc(opts) { + var apiInfo = _cloneDeep(opts.apiInfo); + for (var property in apiInfo) { + property = Array.isArray(property) ? property.join('') : property; + } + return { swaggerVersion: opts.swaggerVersion, apiVersion: opts.version, // See https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#513-info-object - info: opts.apiInfo, + info: apiInfo, // TODO Authorizations // https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#514-authorizations-object consumes: ['application/json', 'application/xml', 'text/xml'],