mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 16:46:34 +03:00
fix: avoid endless recursion in schema-walker in some cases
fixes #418, #395
This commit is contained in:
parent
07d1a7bfc7
commit
309cc23de6
|
@ -53,6 +53,15 @@ class SchemaWalker {
|
||||||
if (obj == undefined || typeof(obj) !== 'object') {
|
if (obj == undefined || typeof(obj) !== 'object') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj['x-redoc-visited']) {
|
||||||
|
const res = visitor(obj, pointer);
|
||||||
|
obj['x-redoc-visited'] = false;
|
||||||
|
// circular, return only title and description
|
||||||
|
return { title: res.title, description: res.description }
|
||||||
|
}
|
||||||
|
|
||||||
|
obj['x-redoc-visited'] = true;
|
||||||
if (obj.properties) {
|
if (obj.properties) {
|
||||||
let ptr = JsonPointer.join(pointer, ['properties']);
|
let ptr = JsonPointer.join(pointer, ['properties']);
|
||||||
SchemaWalker.walkEach(obj.properties, ptr, visitor);
|
SchemaWalker.walkEach(obj.properties, ptr, visitor);
|
||||||
|
@ -83,7 +92,9 @@ class SchemaWalker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return visitor(obj, pointer);
|
const res = visitor(obj, pointer);
|
||||||
|
obj['x-redoc-visited'] = false;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static walkEach(obj:Object, pointer:string, visitor:Function) {
|
private static walkEach(obj:Object, pointer:string, visitor:Function) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user