Skip to content

Commit

Permalink
Validation: fix validation of .avsc files with format option
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Tseluiko authored and Mikhail Tseluiko committed May 26, 2023
1 parent f423dba commit dbe212d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions forward_engineering/helpers/validateAvroScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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:
Expand Down

0 comments on commit dbe212d

Please sign in to comment.