diff --git a/src/ref.js b/src/ref.js index 0575216..5741c90 100644 --- a/src/ref.js +++ b/src/ref.js @@ -2,6 +2,7 @@ // https://github.com/OAI/OpenAPI-Specification/tree/master/versions const FIELD_PATTERN = "([a-zA-Z0-9\\-_]|[^\x01-\x7E\uFF61-\uFF9F])+"; +const MAX_JSON_PATH_DEPTH = 100; const REF_TYPES = { parameters: (path) => { @@ -68,7 +69,10 @@ function getRefType(path) { return k; } } - console.log(`unknown component type at "${path}". fallback to include.`); + console.warn(`could not infer $ref type at "${path}". fallback to include.`); + if (path.split(".").length > MAX_JSON_PATH_DEPTH) { + throw new Error(`JSON path depth exceeds ${MAX_JSON_PATH_DEPTH}, aborting...`); + } return "unknown"; }