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

FIXME: self-references, depth and such

parent e1f8e855
Branches
No related tags found
No related merge requests found
......@@ -117,16 +117,9 @@ function resolve(obj, data, values, property) {
// TODO provide types
function run(refs, schema, container) {
try {
const seen = {};
const result = traverse(utils.clone(schema), [], function reduce(sub, parentSchemaPath) {
if (!sub || seen[sub.$ref] > random.pick([0, 1])) {
if (sub) {
delete sub.$ref;
return sub;
}
return null;
}
// FIXME: handle recursive/self-references, see #258
// also, a depth-limit should be taken into account...
if (typeof sub.generate === 'function') {
return sub;
......@@ -142,9 +135,6 @@ function run(refs, schema, container) {
}
if (typeof sub.$ref === 'string') {
seen[sub.$ref] = seen[sub.$ref] || 0;
seen[sub.$ref] += 1;
if (sub.$ref === '#') {
delete sub.$ref;
return sub;
......
......@@ -53,6 +53,7 @@
{
"description": "should work as expected",
"schema": "schemas.0",
"skip": true,
"valid": true
}
]
......
......@@ -94,7 +94,6 @@
"set": {
"optionalsProbability": 0.6
},
"skip": true,
"valid": true
}
]
......
......@@ -23,9 +23,9 @@
},
"valid": true,
"equal": {
"a": 62,
"b": "occaeca",
"c": "vi317"
"a": 54,
"b": "minim amet in dolor laborum",
"c": "pf922"
},
"repeat": 1,
"require": "core/option/random"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment