2017-11-21 23:43:53 +03:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// Licensed under the MIT License. See License.txt in the project root for license information.
|
|
|
|
|
2018-05-30 07:33:36 +03:00
|
|
|
import assert from 'assert'
|
|
|
|
import * as validate from '../lib/validate'
|
2017-11-21 23:43:53 +03:00
|
|
|
|
|
|
|
describe('Semantic validation', function () {
|
|
|
|
it('should validate correctly when the spec contains an x-ms-parameterized-host', (done) => {
|
|
|
|
let specPath = `${__dirname}/semanticValidation/specification/parameterizedhost/face.json`;
|
2018-05-26 03:18:04 +03:00
|
|
|
validate.validateSpec(specPath, undefined, { consoleLogLevel: 'off' }).then((result: any) => {
|
2017-11-21 23:43:53 +03:00
|
|
|
console.dir(result, { depth: null });
|
|
|
|
assert(result.validityStatus === true, `swagger "${specPath}" contains model validation errors.`);
|
|
|
|
console.log(result);
|
|
|
|
done();
|
2018-05-26 03:18:04 +03:00
|
|
|
}).catch((err: any) => {
|
2017-11-21 23:43:53 +03:00
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
2018-01-12 04:17:09 +03:00
|
|
|
|
|
|
|
it('should validate correctly when the spec does not contain a definitions section', (done) => {
|
|
|
|
let specPath = `${__dirname}/semanticValidation/specification/definitions/definitions.json`;
|
2018-05-26 03:18:04 +03:00
|
|
|
validate.validateSpec(specPath, undefined, { consoleLogLevel: 'off' }).then((result: any) => {
|
2018-01-12 04:17:09 +03:00
|
|
|
console.dir(result, { depth: null });
|
|
|
|
assert(result.validityStatus === true, `swagger "${specPath}" contains model validation errors.`);
|
|
|
|
console.log(result);
|
|
|
|
done();
|
2018-05-26 03:18:04 +03:00
|
|
|
}).catch((err: any) => {
|
2018-01-12 04:17:09 +03:00
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
2017-11-21 23:43:53 +03:00
|
|
|
});
|