Skip to content
Snippets Groups Projects
Commit e5e578a5 authored by Alvaro Cabrera Durán's avatar Alvaro Cabrera Durán
Browse files

Handle recursion and self-references; fixes #258

parent 58e506ac
Branches
Tags
No related merge requests found
......@@ -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;
}
......
......@@ -53,7 +53,6 @@
{
"description": "should work as expected",
"schema": "schemas.0",
"skip": true,
"valid": true
}
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment