mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-11 03:16:48 +03:00
Fix dereference issue caused by invalid circular refs checking
This commit is contained in:
parent
d805cba782
commit
4c4e0a17ed
|
@ -104,7 +104,9 @@ export class BaseComponent {
|
|||
let dereferencedCache = {};
|
||||
|
||||
let resolve = (schema) => {
|
||||
let resolvedRef;
|
||||
if (schema && schema.$ref) {
|
||||
resolvedRef = schema.$ref;
|
||||
let resolved = this.schemaMgr.byPointer(schema.$ref);
|
||||
let baseName = JsonPointer.baseName(schema.$ref);
|
||||
if (!dereferencedCache[schema.$ref]) {
|
||||
|
@ -114,11 +116,12 @@ export class BaseComponent {
|
|||
} else {
|
||||
// for circular referenced save only title and type
|
||||
resolved = {
|
||||
title: resolved.title
|
||||
title: resolved.title,
|
||||
type: resolved.type
|
||||
};
|
||||
}
|
||||
|
||||
dereferencedCache[schema.$ref] = true;
|
||||
dereferencedCache[schema.$ref] = dereferencedCache[schema.$ref] ? dereferencedCache[schema.$ref] + 1 : 1;
|
||||
|
||||
resolved.title = resolved.title || baseName;
|
||||
|
||||
|
@ -133,7 +136,6 @@ export class BaseComponent {
|
|||
schema = schema.description ? {
|
||||
description: schema.description
|
||||
} : {};
|
||||
//for (var prop in schema) delete schema[prop];
|
||||
Object.assign(schema, resolved);
|
||||
}
|
||||
|
||||
|
@ -143,10 +145,11 @@ export class BaseComponent {
|
|||
schema[key] = resolve(value);
|
||||
}
|
||||
});
|
||||
if (resolvedRef) dereferencedCache[resolvedRef] = dereferencedCache[resolvedRef] ? dereferencedCache[resolvedRef] - 1 : 0;
|
||||
return schema;
|
||||
};
|
||||
|
||||
this.componentSchema = resolve(schema);
|
||||
this.componentSchema = resolve(schema, 1);
|
||||
}
|
||||
|
||||
joinAllOf(schema = this.componentSchema, opts) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user