diff --git a/bin/async-validator b/bin/async-validator index c940901..ad1a1dd 100755 --- a/bin/async-validator +++ b/bin/async-validator @@ -5,7 +5,7 @@ const { Command } = require('commander'); const { asyncValidator } = require('../src'); const program = new Command(); -program.version('1.0.2'); +program.version('1.0.3'); program .requiredOption('-f, --file ', 'async api definition') diff --git a/package.json b/package.json index ed2124e..384b284 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jotamusik/async-validator", - "version": "1.0.2", + "version": "1.0.3", "description": "An AsyncAPI schema validator that shows the errors on a definition", "main": "src/index.js", "bin": { @@ -21,7 +21,9 @@ "asyncapi", "validator" ], - "scripts": {}, + "scripts": { + "test": "bin/async-validator -f ../netex/lcloud/asyncapi/definitionV2.yml" + }, "author": "Jorge Aguiar Martin ", "repository": { "type" : "git", diff --git a/src/validateAsyncAPIDefinition.js b/src/validateAsyncAPIDefinition.js index 04a0024..fe02523 100644 --- a/src/validateAsyncAPIDefinition.js +++ b/src/validateAsyncAPIDefinition.js @@ -8,8 +8,12 @@ function validateAsyncAPIDefinition(file) { parser.parse(apiDefinition) .then(() => success('The definition file is correct!!')) .catch(err => { - const errorMessages = err.validationErrors.map(e => `${e.title} ${e.location.startLine}:${e.location.startColumn}`); - errorMessages.forEach(item => error(item)); + if (err.detail) { + error(err.detail); + } else { + const errorMessages = err.validationErrors.map(e => `${e.title} ${e.location.startLine}:${e.location.startColumn}`); + errorMessages.forEach(item => error(item)); + } }); }