Skip to content

Commit

Permalink
validate array type
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljoppi committed Oct 4, 2016
1 parent 4bef839 commit cf31f66
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,13 @@ var processRef = function (property, objectName, props, key, required) {
if (propType !== objectName) {
var object = definitions[propType];
if (~['array', 'object'].indexOf(object.type)) {
var schema = getSchema(propType, definitions[propType]['properties'] ? definitions[propType]['properties'] : definitions[propType]);
props[key] = object.type === 'array' ? [schema] : schema;
var schema = getSchema(propType, object['properties'] ? object['properties'] : object);
props[key] = property['items'] || object.type === 'array' ? [schema] : schema;
} else {
var clone = _.extend({}, object);
delete clone[getMongooseProperty()];
props[key] = getSchemaProperty(clone, key)[key];
var schemaProp = getSchemaProperty(clone, key)[key];
props[key] = property['items'] ? [schemaProp] : schemaProp;
}
} else {
// circular reference
Expand Down Expand Up @@ -334,6 +335,7 @@ module.exports.compile = function (spec, _extraDefinitions) {

var models = {};
_.forEach(schemas, function (schema, key) {
console.log('>>>', key, schema.obj);
models[key] = mongoose.model(key, schema);
});

Expand Down

0 comments on commit cf31f66

Please sign in to comment.