diff --git a/ts/core/run.ts b/ts/core/run.ts index 409003dcd31b70768f0be713450301613ab762f6..e0af74b4ff1684138ea0d46adc49ba7406f3c676 100644 --- a/ts/core/run.ts +++ b/ts/core/run.ts @@ -53,8 +53,8 @@ function run(refs: any, schema: JsonSchema, container: Container) { var _sub = reduce(subSchema, maxReduceDepth + 1); // call given thunks if present - utils.merge(sub, typeof _sub === 'function' - ? _sub() + utils.merge(sub, typeof _sub.thunk === 'function' + ? _sub.thunk() : _sub); }); } @@ -65,12 +65,14 @@ function run(refs: any, schema: JsonSchema, container: Container) { delete sub.anyOf; delete sub.oneOf; - return () => { - var copy = utils.merge({}, sub); + return { + thunk() { + var copy = utils.merge({}, sub); - utils.merge(copy, random.pick(mix)); + utils.merge(copy, random.pick(mix)); - return copy; + return copy; + }, }; } diff --git a/ts/core/traverse.ts b/ts/core/traverse.ts index 9491d8bed7e378deda14d6dc1036be747ddd855e..c264847db5e511d283ac1a5189a18746251ee22d 100644 --- a/ts/core/traverse.ts +++ b/ts/core/traverse.ts @@ -18,8 +18,8 @@ function traverse(schema: JsonSchema, path: SchemaPath, resolve: Function) { } // thunks can return sub-schemas - if (typeof schema === 'function') { - return traverse(schema(), path, resolve); + if (typeof schema.thunk === 'function') { + return traverse(schema.thunk(), path, resolve); } if (typeof schema.generate === 'function') {