Add field caching to avoid out of memory exception.

This commit is contained in:
Urs Brogle 2020-02-15 23:05:47 +01:00
parent c05db38576
commit 02c1f4d72a

View File

@ -275,12 +275,17 @@ export class SchemaModel {
}
}
const fieldCache: { [index: string]: FieldModel[] } = {};
function buildFields(
parser: OpenAPIParser,
schema: OpenAPISchema,
$ref: string,
options: RedocNormalizedOptions,
): FieldModel[] {
if (fieldCache[$ref]) {
return fieldCache[$ref];
}
const props = schema.properties || {};
const additionalProps = schema.additionalProperties;
const defaults = schema.default || {};
@ -339,6 +344,8 @@ function buildFields(
);
}
fieldCache[$ref] = fields;
return fields;
}