diff --git a/ChangeLog.md b/ChangeLog.md index 71f39f3b..d7d55d4b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,9 @@ +### 04/23/2018 0.4.37 +- Update dependencies. +- Bug fixes: + - Path parameters can include single quotes and be evaluated succesfully. + - Enums with non-string values are properly evaluated. + ### 04/19/2018 0.4.36 - If enums mismatch only in casing the new error ENUM_CASE_MISMATCH will be returned. diff --git a/package-lock.json b/package-lock.json index 78212753..3c21c2a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "oav", - "version": "0.4.36", + "version": "0.4.37", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3073,7 +3073,7 @@ } }, "sway": { - "version": "github:amarzavery/sway#02ede38a836bb39b76313ca779e59c6a5144d312", + "version": "github:amarzavery/sway#32784bab1cba7178bd4bf283cb4c6fdfafd15627", "requires": { "debug": "3.1.0", "faker": "4.1.0", @@ -3432,4 +3432,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 53848015..3127e217 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oav", - "version": "0.4.36", + "version": "0.4.37", "author": { "name": "Microsoft Corporation", "email": "azsdkteam@microsoft.com", @@ -55,4 +55,4 @@ "test": "npm -s run-script jshint && mocha -t 100000 --reporter min", "start": "node ./lib/autorestPlugin/pluginHost.js" } -} +} \ No newline at end of file diff --git a/test/modelValidation/swaggers/specification/scenarios/resource-manager/Microsoft.Test/2016-01-01/examples/pathwithquotes.json b/test/modelValidation/swaggers/specification/scenarios/resource-manager/Microsoft.Test/2016-01-01/examples/pathwithquotes.json new file mode 100644 index 00000000..0113013e --- /dev/null +++ b/test/modelValidation/swaggers/specification/scenarios/resource-manager/Microsoft.Test/2016-01-01/examples/pathwithquotes.json @@ -0,0 +1,8 @@ +{ + "parameters": { + "quotes": "coolparameter" + }, + "responses": { + "200": {} + } +} \ No newline at end of file diff --git a/test/modelValidation/swaggers/specification/scenarios/resource-manager/Microsoft.Test/2016-01-01/test.json b/test/modelValidation/swaggers/specification/scenarios/resource-manager/Microsoft.Test/2016-01-01/test.json index decd9638..d4933ec8 100644 --- a/test/modelValidation/swaggers/specification/scenarios/resource-manager/Microsoft.Test/2016-01-01/test.json +++ b/test/modelValidation/swaggers/specification/scenarios/resource-manager/Microsoft.Test/2016-01-01/test.json @@ -18,6 +18,31 @@ "text/json" ], "paths": { + "/param('{quotes}')": { + "put": { + "operationId": "Path_WithQuotes", + "description": "The path has a parameter between quotes", + "x-ms-examples": { + "PathWithQuotes": { + "$ref": "./examples/pathwithquotes.json" + } + }, + "parameters": [ + { + "name": "quotes", + "in": "path", + "required": true, + "type": "string", + "description": "Parameter meant to be between quotes" + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/subscriptions/{scope}/providers/Microsoft.Test/checkNameAvailability": { "post": { "tags": [ @@ -26,7 +51,9 @@ "operationId": "StorageAccounts_CheckNameAvailability", "description": "Checks that the storage account name is valid and is not already in use.", "x-ms-examples": { - "storageAccountCheckNameAvailability": {"$ref": "./examples/storageAccountCheckNameAvailability.json"} + "storageAccountCheckNameAvailability": { + "$ref": "./examples/storageAccountCheckNameAvailability.json" + } }, "parameters": [ { @@ -67,7 +94,9 @@ "operationId": "StorageAccounts_pathParameterWithForwardSlashes", "description": "Checks that the storage account name is valid and is not already in use.", "x-ms-examples": { - "storageAccountPathParameterForwardSlash": {"$ref": "./examples/storageAccountPathParameterForwardSlash.json"} + "storageAccountPathParameterForwardSlash": { + "$ref": "./examples/storageAccountPathParameterForwardSlash.json" + } }, "parameters": [ { @@ -108,7 +137,9 @@ "operationId": "StorageAccounts_duplicateforwardslashes", "description": "Checks that the storage account name is valid and is not already in use.", "x-ms-examples": { - "storageAccountduplicateforwardslashes": {"$ref": "./examples/storageAccountduplicateforwardslashes.json"} + "storageAccountduplicateforwardslashes": { + "$ref": "./examples/storageAccountduplicateforwardslashes.json" + } }, "parameters": [ { @@ -151,7 +182,9 @@ "operationId": "StorageAccounts_pathParameterWithQuestionMark", "description": "Checks that the storage account name is valid and is not already in use.", "x-ms-examples": { - "storageAccountXmsPaths": {"$ref": "./examples/storageAccountXmsPaths.json"} + "storageAccountXmsPaths": { + "$ref": "./examples/storageAccountXmsPaths.json" + } }, "parameters": [ { diff --git a/test/modelValidatorTests.js b/test/modelValidatorTests.js index e730f509..0f0ce1d8 100644 --- a/test/modelValidatorTests.js +++ b/test/modelValidatorTests.js @@ -6,42 +6,55 @@ const validate = require('../lib/validate'); const specPath = `${__dirname}/modelValidation/swaggers/specification/scenarios/resource-manager/Microsoft.Test/2016-01-01/test.json`; describe('Model Validation', function () { - it('should pass when path parameter has forward slashes', function (done) { - let operationIds = "StorageAccounts_pathParameterWithForwardSlashes"; - validate.validateExamples(specPath, operationIds, { consoleLogLevel: 'off' }).then((result) => { - assert(result.validityStatus === true, `swagger "${specPath}" with operation "${operationIds}" contains model validation errors.`); - console.log(result); - done(); - }).catch((err) => { - done(err); + describe('Path validation - ', function () { + it('should pass when path parameter has forward slashes', function (done) { + let operationIds = "StorageAccounts_pathParameterWithForwardSlashes"; + validate.validateExamples(specPath, operationIds, { consoleLogLevel: 'off' }).then((result) => { + assert(result.validityStatus === true, `swagger "${specPath}" with operation "${operationIds}" contains model validation errors.`); + console.log(result); + done(); + }).catch((err) => { + done(err); + }); }); - }); - it('should pass for paths in x-ms-paths with question mark', function (done) { - let operationIds = "StorageAccounts_pathParameterWithQuestionMark"; - validate.validateExamples(specPath, operationIds, { consoleLogLevel: 'off' }).then((result) => { - assert(result.validityStatus === true, `swagger "${specPath}" with operation "${operationIds}" contains model validation errors.`); - console.log(result); - done(); - }).catch((err) => { - done(err); + it('should pass for paths in x-ms-paths with question mark', function (done) { + let operationIds = "StorageAccounts_pathParameterWithQuestionMark"; + validate.validateExamples(specPath, operationIds, { consoleLogLevel: 'off' }).then((result) => { + assert(result.validityStatus === true, `swagger "${specPath}" with operation "${operationIds}" contains model validation errors.`); + console.log(result); + done(); + }).catch((err) => { + done(err); + }); + }); + + it('should pass for paths with quotes', function (done) { + let operationIds = "Path_WithQuotes"; + validate.validateExamples(specPath, operationIds, { consoleLogLevel: 'off' }).then((result) => { + assert(result.validityStatus === true, `swagger "${specPath}" with operation "${operationIds}" contains model validation errors.`); + console.log(result); + done(); + }).catch((err) => { + done(err); + }); }); - }); - it('should fail for paths with path parameter value resulting in duplicate forward slashes', function (done) { - let operationIds = "StorageAccounts_duplicateforwardslashes"; - validate.validateExamples(specPath, operationIds, { consoleLogLevel: 'off' }).then((result) => { - assert(result.validityStatus === false, `swagger "${specPath}" with operation "${operationIds}" contains passed incorrectly.`); - console.log(result); - done(); - }).catch((err) => { - try { - assert.equal(err.code, 'REQUEST_VALIDATION_ERROR'); - assert.equal(err.innerErrors[0].code, 'DOUBLE_FORWARD_SLASHES_IN_URL'); + it('should fail for paths with path parameter value resulting in duplicate forward slashes', function (done) { + let operationIds = "StorageAccounts_duplicateforwardslashes"; + validate.validateExamples(specPath, operationIds, { consoleLogLevel: 'off' }).then((result) => { + assert(result.validityStatus === false, `swagger "${specPath}" with operation "${operationIds}" contains passed incorrectly.`); + console.log(result); done(); - } catch (er) { - done(er); - } + }).catch((err) => { + try { + assert.equal(err.code, 'REQUEST_VALIDATION_ERROR'); + assert.equal(err.innerErrors[0].code, 'DOUBLE_FORWARD_SLASHES_IN_URL'); + done(); + } catch (er) { + done(er); + } + }); }); });