add test for semantic validation
This commit is contained in:
Родитель
f405369a4e
Коммит
700cb47dd4
|
@ -468,7 +468,7 @@ class SpecResolver {
|
|||
* SemanticValidation:
|
||||
* This step should not be performed for semantic validation, othwerise there will
|
||||
* be a mismatch between the number of path parameters provided in the operation
|
||||
* definition and the number pf parameters actually present in the path template.
|
||||
* definition and the number of parameters actually present in the path template.
|
||||
*/
|
||||
resolveParameterizedHost() {
|
||||
let self = this;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"version": "2017-08-30",
|
||||
"title": "Common Referenced Parameters File",
|
||||
"description": "File containing commonly referenced parameters."
|
||||
},
|
||||
"paths": {},
|
||||
"parameters": {
|
||||
"AzureRegion": {
|
||||
"name": "AzureRegion",
|
||||
"description": "Supported Azure regions for Cognitive Services endpoints",
|
||||
"x-ms-parameter-location": "client",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"in": "path",
|
||||
"x-ms-skip-url-encoding": true,
|
||||
"x-ms-enum": {
|
||||
"name": "AzureRegions",
|
||||
"modelAsString": false
|
||||
},
|
||||
"enum": [
|
||||
"westus",
|
||||
"westeurope",
|
||||
"southeastasia",
|
||||
"eastus2",
|
||||
"westcentralus",
|
||||
"westus2",
|
||||
"eastus",
|
||||
"southcentralus",
|
||||
"northeurope",
|
||||
"eastasia",
|
||||
"australiaeast",
|
||||
"brazilsouth"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"version": "2017-08-30",
|
||||
"title": "Common Referenced Parameters File",
|
||||
"description": "File containing commonly referenced parameters."
|
||||
},
|
||||
"paths": {},
|
||||
"parameters": {
|
||||
"ImageStream": {
|
||||
"name": "Image",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"x-ms-parameter-location": "method",
|
||||
"description": "An image stream.",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"format": "file"
|
||||
}
|
||||
},
|
||||
"ImageUrl": {
|
||||
"name": "ImageUrl",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"x-ms-parameter-location": "method",
|
||||
"x-ms-client-flatten": true,
|
||||
"description": "A JSON document with a URL pointing to the image that is to be analyzed.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ImageUrl"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"ImageUrl": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
const assert = require('assert');
|
||||
const validate = require('../lib/validate');
|
||||
|
||||
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`;
|
||||
validate.validateSpec(specPath, undefined, { consoleLogLevel: 'off' }).then((result) => {
|
||||
console.dir(result, { depth: null });
|
||||
assert(result.validityStatus === true, `swagger "${specPath}" contains model validation errors.`);
|
||||
console.log(result);
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
Загрузка…
Ссылка в новой задаче