diff --git a/src/core/run.js b/src/core/run.js index f672b180d7c0ef244dac97b31432df4efa13353a..f7fda592f0ddc3cfbb5e8b5199c33e512b7e629a 100644 --- a/src/core/run.js +++ b/src/core/run.js @@ -116,11 +116,10 @@ function resolve(obj, data, values, property) { // TODO provide types function run(refs, schema, container) { + let depth = 0; + try { const result = traverse(utils.clone(schema), [], function reduce(sub, parentSchemaPath) { - // FIXME: handle recursive/self-references, see #258 - // also, a depth-limit should be taken into account... - if (typeof sub.generate === 'function') { return sub; } @@ -135,7 +134,7 @@ function run(refs, schema, container) { } if (typeof sub.$ref === 'string') { - if (sub.$ref === '#') { + if (sub.$ref === '#' || ++depth > random.number(0, 2)) { delete sub.$ref; return sub; } diff --git a/tests/schema/core/issues/issue-258.json b/tests/schema/core/issues/issue-258.json index 8da1ff1b57657577ea2a13db74f4c2df31a35ad6..c54c40796ef35dd59ecc1a17b3e25c7444bac263 100644 --- a/tests/schema/core/issues/issue-258.json +++ b/tests/schema/core/issues/issue-258.json @@ -53,7 +53,6 @@ { "description": "should work as expected", "schema": "schemas.0", - "skip": true, "valid": true } ]