Skip to content

Commit

Permalink
Fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mokkabonna committed Oct 16, 2017
1 parent 945e537 commit cc84550
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
19 changes: 5 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,14 @@ var mixin = {
var self = this
return reduce(normalizedSchemas, function(all, schema) {
var root = self
var data = createDataProperties(normalizedSchemas)
var flatStructure = isPlainObject(data) ? flattenObject(data) : {}

if (schemaConfig.mountPoint !== '.' && !originallyArray) {
data = get(self, schemaConfig.mountPoint)
flatStructure = isPlainObject(data) ? flattenObject(data) : {}
root = get(self, schemaConfig.mountPoint)

if (isPlainObject(root)) {
flatStructure = reduce(flatStructure, function(all, val, key) {
all[String(key).replace(schemaConfig.mountPoint, '').replace(/^\./, '')] = val
return all
}, {})
} else {
return root
}
return get(self, schemaConfig.mountPoint)
}

var data = createDataProperties(normalizedSchemas)
var flatStructure = isPlainObject(data) ? flattenObject(data) : {}

return reduce(flatStructure, function(all, val, path) {
return set(all, path, get(root, path))
}, all)
Expand Down
4 changes: 2 additions & 2 deletions test/specs/schemas.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('schema fixtures validation', function() {
return Promise.all(innerSchema.map(function(config) {
if (_.isPlainObject(config.schema)) {
return $RefParser.dereference(config.schema).then(function(dereferenced) {
innerSchema.schema = dereferenced
return innerSchema
config.schema = dereferenced
return config
})
} else {
innerSchema.schema = config.schema
Expand Down

0 comments on commit cc84550

Please sign in to comment.