mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-10 15:14:54 +03:00
Add field caching to avoid out of memory exception.
This commit is contained in:
parent
c05db38576
commit
02c1f4d72a
|
@ -275,12 +275,17 @@ export class SchemaModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fieldCache: { [index: string]: FieldModel[] } = {};
|
||||||
|
|
||||||
function buildFields(
|
function buildFields(
|
||||||
parser: OpenAPIParser,
|
parser: OpenAPIParser,
|
||||||
schema: OpenAPISchema,
|
schema: OpenAPISchema,
|
||||||
$ref: string,
|
$ref: string,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
): FieldModel[] {
|
): FieldModel[] {
|
||||||
|
if (fieldCache[$ref]) {
|
||||||
|
return fieldCache[$ref];
|
||||||
|
}
|
||||||
const props = schema.properties || {};
|
const props = schema.properties || {};
|
||||||
const additionalProps = schema.additionalProperties;
|
const additionalProps = schema.additionalProperties;
|
||||||
const defaults = schema.default || {};
|
const defaults = schema.default || {};
|
||||||
|
@ -339,6 +344,8 @@ function buildFields(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldCache[$ref] = fields;
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user