diff --git a/.eslintrc.yml b/.eslintrc.yml index 2e4cdbd..327c4d0 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -4,7 +4,7 @@ env: mocha: true extends: 'eslint:recommended' parserOptions: - ecmaVersion: 8 + ecmaVersion: 2020 sourceType: 'script' rules: indent: diff --git a/index.js b/index.js index 79794e8..6d9f99f 100755 --- a/index.js +++ b/index.js @@ -395,11 +395,17 @@ require('yargs') type: 'boolean', default: false, }); + yargs.option('disableValidation', { + describe: 'Do not validate generated output', + type: 'boolean', + default: false + }); }, argv => { return Commands.generate(argv.model, argv.concept, argv.mode, { optionalFields: argv.includeOptionalFields, metamodel: argv.metamodel, strict: argv.strict, + disableValidation: argv.disableValidation }) .then(obj => { console.log(JSON.stringify(obj, null, 2)); diff --git a/lib/commands.js b/lib/commands.js index ee3c807..bbe1681 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -305,6 +305,7 @@ class Commands { * @param {string} [options.optionalFields] if true, optional fields will be included in the output * @param {boolean} [options.strict] - require versioned namespaces and imports * @param {boolean} [options.metamodel] - include the Concerto Metamodel + * @param {boolean} [options.disableValidation] - do not validate the generated output */ static async generate(ctoFiles, concept, mode, options) { const modelManagerOptions = { offline: options && options.offline, strict: options && options.strict }; @@ -342,7 +343,7 @@ class Commands { ); const serializer = new Serializer(factory, modelManager); - return Promise.resolve(serializer.toJSON(resource)); + return Promise.resolve(serializer.toJSON(resource, {validate: !options?.disableValidation})); } /**