Skip to content

Commit

Permalink
fix(schema): handle setting nested paths underneath single nested sub…
Browse files Browse the repository at this point in the history
…docs

Fix #9459
  • Loading branch information
vkarpov15 committed Oct 4, 2020
1 parent 18973c0 commit 978d695
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,9 @@ Schema.prototype.path = function(path, obj) {
this.singleNestedPaths[path + '.' + key] =
schemaType.schema.subpaths[key];
}
for (const key in schemaType.schema.nested) {
this.singleNestedPaths[path + '.' + key] = 'nested';
}

Object.defineProperty(schemaType.schema, 'base', {
configurable: true,
Expand Down Expand Up @@ -1124,8 +1127,10 @@ Schema.prototype.pathType = function(path) {
if (this.subpaths.hasOwnProperty(cleanPath) || this.subpaths.hasOwnProperty(path)) {
return 'real';
}
if (this.singleNestedPaths.hasOwnProperty(cleanPath) || this.singleNestedPaths.hasOwnProperty(path)) {
return 'real';

const singleNestedPath = this.singleNestedPaths.hasOwnProperty(cleanPath) || this.singleNestedPaths.hasOwnProperty(path);
if (singleNestedPath) {
return singleNestedPath === 'nested' ? 'nested' : 'real';
}

// Look for maps
Expand Down

0 comments on commit 978d695

Please sign in to comment.