Skip to main content
Sign in
Snippets Groups Projects
Commit f3a3d1be authored by Alvaro Cabrera's avatar Alvaro Cabrera
Browse files

Return thunk() within object; fix

parent 328c17f1
No related branches found
No related tags found
No related merge requests found
...@@ -53,8 +53,8 @@ function run(refs: any, schema: JsonSchema, container: Container) { ...@@ -53,8 +53,8 @@ function run(refs: any, schema: JsonSchema, container: Container) {
var _sub = reduce(subSchema, maxReduceDepth + 1); var _sub = reduce(subSchema, maxReduceDepth + 1);
// call given thunks if present // call given thunks if present
utils.merge(sub, typeof _sub === 'function' utils.merge(sub, typeof _sub.thunk === 'function'
? _sub() ? _sub.thunk()
: _sub); : _sub);
}); });
} }
...@@ -65,12 +65,14 @@ function run(refs: any, schema: JsonSchema, container: Container) { ...@@ -65,12 +65,14 @@ function run(refs: any, schema: JsonSchema, container: Container) {
delete sub.anyOf; delete sub.anyOf;
delete sub.oneOf; delete sub.oneOf;
return () => { return {
thunk() {
var copy = utils.merge({}, sub); var copy = utils.merge({}, sub);
utils.merge(copy, random.pick(mix)); utils.merge(copy, random.pick(mix));
return copy; return copy;
},
}; };
} }
... ...
......
...@@ -18,8 +18,8 @@ function traverse(schema: JsonSchema, path: SchemaPath, resolve: Function) { ...@@ -18,8 +18,8 @@ function traverse(schema: JsonSchema, path: SchemaPath, resolve: Function) {
} }
// thunks can return sub-schemas // thunks can return sub-schemas
if (typeof schema === 'function') { if (typeof schema.thunk === 'function') {
return traverse(schema(), path, resolve); return traverse(schema.thunk(), path, resolve);
} }
if (typeof schema.generate === 'function') { if (typeof schema.generate === 'function') {
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment