From dbe212d673f76c09ed4c133114dd980811c47cce Mon Sep 17 00:00:00 2001 From: Mikhail Tseluiko Date: Fri, 26 May 2023 15:04:48 +0300 Subject: [PATCH] Validation: fix validation of .avsc files with format option --- forward_engineering/helpers/validateAvroScript.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/forward_engineering/helpers/validateAvroScript.js b/forward_engineering/helpers/validateAvroScript.js index 32b3a72..a5ce87c 100644 --- a/forward_engineering/helpers/validateAvroScript.js +++ b/forward_engineering/helpers/validateAvroScript.js @@ -18,6 +18,7 @@ let _; const validateAvroScript = (script, scriptType, logger) => { _ = dependencies.lodash; + scriptType = detectScriptType(script) || scriptType; const scripts = parseScript(script, scriptType); const validator = getScriptValidator(scriptType); @@ -29,6 +30,12 @@ const validateAvroScript = (script, scriptType, logger) => { return getMessageForMultipleSchemaValidation(_.flatten(validationMessages)); }; +const detectScriptType = script => { + if (parseJson(script).type) { + return SCRIPT_TYPES.COMMON; + } +}; + const parseScript = (script, scriptType) =>{ switch(scriptType){ case SCRIPT_TYPES.CONFLUENT_SCHEMA_REGISTRY: