diff --git a/.travis.yml b/.travis.yml index b915eb0a16c1..4af13ebd635f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,7 +87,7 @@ script: fi - >- if [[ $MODE == 'model' ]]; then - npm test -- test/model.js + node scripts/modelValidation.js fi - >- if [[ $MODE == 'BreakingChange' ]]; then diff --git a/package.json b/package.json index 5ccf00b8cf1c..00d83d53243a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "json-schema-ref-parser": "^3.1.2", "mocha": "*", "oad": "^0.1.11", - "oav": "^0.4.44", + "oav": "^0.4.57", "request": "^2.61.0", "request-promise-native": "^1.0.5", "z-schema": "^3.16.1" diff --git a/scripts/modelValidation.js b/scripts/modelValidation.js new file mode 100644 index 000000000000..7cc0dc62611d --- /dev/null +++ b/scripts/modelValidation.js @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License in the project root for license information. +'use strict'; + +const utils = require('../test/util/utils') +const oav = require('oav'); + +async function main() { + const swaggersToProcess = utils.getFilesChangedInPR(); + // Useful when debugging a test for a particular swagger. + // Just update the regex. That will return an array of filtered items. + // swaggersToProcess = swaggersToProcess.filter(function(item) { + // return (item.match(/.*Microsoft.Logic.*2016-06-01.*/ig) !== null); + // }); + for (const swagger of swaggersToProcess) { + await oav.validateExamples(swagger, null, {consoleLogLevel: 'error', pretty: true}); + } +} + +main() \ No newline at end of file diff --git a/test/model.js b/test/model.js deleted file mode 100644 index 4648425cb72d..000000000000 --- a/test/model.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License in the project root for license information. - -'use strict'; -var assert = require('assert'), - utils = require('./util/utils'), - oav = require('oav'); - -describe('Azure swagger model validation using x-ms-examples and examples in spec', function () { - let swaggersToProcess = utils.getFilesChangedInPR(); - // Useful when debugging a test for a particular swagger. - // Just update the regex. That will return an array of filtered items. - // swaggersToProcess = swaggersToProcess.filter(function(item) { - // return (item.match(/.*Microsoft.Logic.*2016-06-01.*/ig) !== null); - // }); - for (const swagger of swaggersToProcess) { - it(swagger + ' should have valid examples.', async function () { - try { - const validationResult = await oav.validateExamples(swagger, null, {consoleLogLevel: 'error'}); - return assert( - validationResult.validityStatus === true, - `swagger "${swagger}" contains model validation errors.`); - } catch (err) { - console.dir(err, {depth: null, colors: true}); - throw err; - } - }); - } -}); \ No newline at end of file