Skip to content

Commit

Permalink
feat(generate): add option to disable output validation
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman committed Jul 23, 2024
1 parent 00fc809 commit 8e37073
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 411 in index.js

View workflow job for this annotation

GitHub Actions / Unit Tests (16.x, ubuntu-latest)

Unexpected console statement

Check warning on line 411 in index.js

View workflow job for this annotation

GitHub Actions / Unit Tests (18.x, ubuntu-latest)

Unexpected console statement

Check warning on line 411 in index.js

View workflow job for this annotation

GitHub Actions / Unit Tests (18.x, macOS-latest)

Unexpected console statement
Expand Down
3 changes: 2 additions & 1 deletion lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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}));
}

/**
Expand Down

0 comments on commit 8e37073

Please sign in to comment.