Skip to content

Commit

Permalink
fix: rework recursive references, closes #584
Browse files Browse the repository at this point in the history
  • Loading branch information
pateketrueke committed Nov 11, 2020
1 parent 581aeb2 commit ce42af1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/lib/core/buildResolveSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ const buildResolveSchema = ({
// this is the only case where all sub-schemas
// must be resolved before any merge
schemas.forEach(subSchema => {
const _sub = recursiveUtil.resolveSchema(subSchema, null, rootPath);
const _sub = resolveSchema(subSchema, null, rootPath);

// call given thunks if present
utils.merge(sub, typeof _sub.thunk === 'function'
? _sub.thunk(sub)
: _sub);
if (Array.isArray(sub.allOf)) {
recursiveUtil.resolveSchema(sub, index, rootPath);
resolveSchema(sub, index, rootPath);
}
});
}
Expand Down Expand Up @@ -130,7 +130,7 @@ const buildResolveSchema = ({

Object.keys(sub).forEach(prop => {
if ((Array.isArray(sub[prop]) || typeof sub[prop] === 'object') && !utils.isKey(prop)) {
sub[prop] = recursiveUtil.resolveSchema(sub[prop], prop, rootPath.concat(prop));
sub[prop] = resolveSchema(sub[prop], prop, rootPath.concat(prop));
}
});

Expand All @@ -146,7 +146,7 @@ const buildResolveSchema = ({
return container.wrap(sub);
};

return recursiveUtil;
return resolveSchema;
};

export default buildResolveSchema;
2 changes: 1 addition & 1 deletion src/lib/core/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function run(refs, schema, container) {
const refDepthMax = optionAPI('refDepthMax') || 3;

try {
const { resolveSchema } = buildResolveSchema({
const resolveSchema = buildResolveSchema({
refs,
schema,
container,
Expand Down
6 changes: 1 addition & 5 deletions tests/schema/core/option/refDepth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@
{
"subA": [
{
"subA": [
{
"subA": []
}
]
"subA": []
}
]
}
Expand Down

0 comments on commit ce42af1

Please sign in to comment.