Pretty printing for semantic errors (validate-spec command) (#315)

* Adding reference documentation for oav model validation

* adding pretty printing to validate-spec command

* adding changelog
This commit is contained in:
Veronica Giaudrone 2018-09-19 14:37:07 -07:00 коммит произвёл Sergey Shandar
Родитель 43d4fbe615
Коммит fcfbef76ab
4 изменённых файлов: 46 добавлений и 17 удалений

Просмотреть файл

@ -1,5 +1,9 @@
# Changelog
### 09/19/2018 0.5.11
- Adding pretty printing to validate-spec command, --pretty option.
### 09/17/2018 0.5.10
- xMsExamplesExtractor bug fix #309

Просмотреть файл

@ -104,9 +104,34 @@ export async function validateSpec(
await validator.initialize()
log.info(`Semantically validating ${specPath}:\n`)
await validator.validateSpec()
const validationResults = await validator.validateSpec()
updateEndResultOfSingleValidation(validator)
logDetailedInfo(validator)
logDetailedInfo(validator)
if (o.pretty) {
/* tslint:disable-next-line:no-console no-string-literal */
console.log(`Semantically validating ${specPath}:\n`)
const errors = validationResults.errors
if (errors.length > 0) {
for (const error of errors) {
const yaml = jsYaml.dump(error)
/* tslint:disable-next-line:no-console no-string-literal */
console.error("\x1b[31m", "error:", "\x1b[0m")
/* tslint:disable-next-line:no-console no-string-literal */
console.error(yaml)
}
}
const warnings = validationResults.warnings
if (warnings && warnings.length > 0) {
for (const warning of warnings) {
const yaml = jsYaml.dump(warning)
/* tslint:disable-next-line:no-console no-string-literal */
console.warn("\x1b[31m", "warning:", "\x1b[0m")
/* tslint:disable-next-line:no-console no-string-literal */
console.warn(yaml)
}
}
}
return validator.specValidationResult
})
}

30
package-lock.json сгенерированный
Просмотреть файл

@ -247,7 +247,7 @@
"dependencies": {
"acorn": {
"version": "3.3.0",
"resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
"integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo="
}
}
@ -440,7 +440,7 @@
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=",
"requires": {
"ms": "2.0.0"
}
@ -498,7 +498,7 @@
},
"readable-stream": {
"version": "1.1.14",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"requires": {
"core-util-is": "~1.0.0",
@ -684,7 +684,7 @@
"commander": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ=="
"integrity": "sha1-FXFS/R56bI2YpbcVzzdt+SgARWM="
},
"component-emitter": {
"version": "1.2.1",
@ -710,7 +710,7 @@
"content-type": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
"integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
"integrity": "sha1-4TjMdeBAxyexlm/l5fjJruJW/js="
},
"cookiejar": {
"version": "2.1.2",
@ -753,7 +753,7 @@
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
"requires": {
"ms": "2.0.0"
}
@ -843,7 +843,7 @@
},
"readable-stream": {
"version": "1.1.14",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"requires": {
"core-util-is": "~1.0.0",
@ -973,7 +973,7 @@
},
"eslint": {
"version": "4.19.1",
"resolved": "http://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz",
"integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==",
"requires": {
"ajv": "^5.3.0",
@ -1131,7 +1131,7 @@
},
"external-editor": {
"version": "2.2.0",
"resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz",
"integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==",
"requires": {
"chardet": "^0.4.0",
@ -1385,7 +1385,7 @@
},
"http-errors": {
"version": "1.6.3",
"resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
"integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=",
"requires": {
"depd": "~1.1.2",
@ -1407,7 +1407,7 @@
"iconv-lite": {
"version": "0.4.19",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
"integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
"integrity": "sha1-90aPYBNfXl2tM5nAqBvpoWA6CCs="
},
"ignore": {
"version": "3.3.10",
@ -2134,7 +2134,7 @@
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
"requires": {
"brace-expansion": "^1.1.7"
}
@ -2288,7 +2288,7 @@
"normalize-package-data": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
"integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==",
"integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=",
"requires": {
"hosted-git-info": "^2.1.4",
"is-builtin-module": "^1.0.0",
@ -5207,7 +5207,7 @@
},
"readable-stream": {
"version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"requires": {
"core-util-is": "~1.0.0",
@ -5957,7 +5957,7 @@
"tunnel": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.5.tgz",
"integrity": "sha512-gj5sdqherx4VZKMcBA4vewER7zdK25Td+z1npBqpbDys4eJrLx+SlYjJvq1bDXs2irkuJM5pf8ktaEQVipkrbA=="
"integrity": "sha1-0VMiVHSe02Yg/NEBCGVJWh+p0K4="
},
"tunnel-agent": {
"version": "0.6.0",

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "oav",
"version": "0.5.10",
"version": "0.5.11",
"author": {
"name": "Microsoft Corporation",
"email": "azsdkteam@microsoft.com",