updating error msgs

This commit is contained in:
Carlos_Veloz
2022-04-19 10:29:31 -05:00
parent 90a191dc4c
commit 1e40506157
3 changed files with 27 additions and 27 deletions

View File

@@ -10,25 +10,25 @@ module.exports = {
if (spec.swagger !== '2.0') {
return {
result: false,
reason: 'The Swagger object must have the "swagger" property set to 2.0'
reason: 'The value of swagger field must be 2.0'
};
}
if (!spec.info) {
return {
result: false,
reason: 'The Swagger object must have an "info" property'
reason: 'The Swagger specification must have an "info" field'
};
}
if (!(spec.info.title && spec.info.version)) {
return {
result: false,
reason: 'The info property must have title and version defined'
reason: 'Title, and version fields are required for the Info Object'
};
}
if (!spec.paths) {
return {
result: false,
reason: 'The Swagger object must have a "paths" property'
reason: 'The Swagger specification must have a "paths" field'
};
}

38
package-lock.json generated
View File

@@ -459,7 +459,7 @@
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"requires": {
"sprintf-js": "~1.0.2"
}
@@ -674,7 +674,7 @@
"cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha1-UR1wLAxOQcoVbX0OlgIfI+EyJbE=",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"requires": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
@@ -684,7 +684,7 @@
"ansi-regex": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha1-OIU59VF5vzkznIGvMKZU1p+Hy3U="
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg=="
},
"string-width": {
"version": "4.2.0",
@@ -699,7 +699,7 @@
"strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
"integrity": "sha1-CxVx3XZpzNTz4G4U7x7tJiJa5TI=",
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
"requires": {
"ansi-regex": "^5.0.0"
}
@@ -1144,7 +1144,7 @@
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha1-E7BM2z5sXRnfkatph6hpVhmwqnE="
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
},
"esquery": {
"version": "1.0.1",
@@ -1218,7 +1218,7 @@
"fast-safe-stringify": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz",
"integrity": "sha1-EkqohYmSYfaK7bQqfAgN6dpgh0M="
"integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA=="
},
"figures": {
"version": "3.0.0",
@@ -1266,7 +1266,7 @@
"find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha1-l6/n1s3AvFkoWEt8jXsW6KmqXRk=",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"requires": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
@@ -1533,7 +1533,7 @@
"http2-client": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/http2-client/-/http2-client-1.3.3.tgz",
"integrity": "sha1-kPwV1kbMqGlWsVbQfIOUfVfWWak="
"integrity": "sha512-nUxLymWQ9pzkzTmir24p2RtsgruLmhje7lH3hLX1IpwvyTg77fW+1brenPPP3USAR+rQ36p5sTA/x7sjCJVkAA=="
},
"iconv-lite": {
"version": "0.4.24",
@@ -2009,7 +2009,7 @@
"locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha1-Gvujlq/WdqbUJQTQpno6frn2KqA=",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"requires": {
"p-locate": "^4.1.0"
}
@@ -2378,7 +2378,7 @@
"node-fetch-h2": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/node-fetch-h2/-/node-fetch-h2-2.3.0.tgz",
"integrity": "sha1-xhiDJfm9PYNAIL8PLW3BfO0iQaw=",
"integrity": "sha512-ofRW94Ab0T4AOh5Fk8t0h8OBWrmjb0SSB20xh1H8YnPV9EJ+f5AMoYSUQ2zgJ4Iq2HAK0I2l5/Nequ8YzFS3Hg==",
"requires": {
"http2-client": "^1.2.5"
}
@@ -2481,7 +2481,7 @@
"oas-kit-common": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/oas-kit-common/-/oas-kit-common-1.0.8.tgz",
"integrity": "sha1-bYys9ukJeWekx+qLy8vXcBjh9TU=",
"integrity": "sha512-pJTS2+T0oGIwgjGpw7sIRU8RQMcUoKCDWFLdBqKB2BNmGpbBMH2sdqAaOXUg8OzonZHU0L7vfJu1mJFEiYDWOQ==",
"requires": {
"fast-safe-stringify": "^2.0.7"
}
@@ -2720,7 +2720,7 @@
"p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha1-o0KLtwiLOmApL2aRkni3wpetTwc=",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"requires": {
"p-limit": "^2.2.0"
}
@@ -2778,7 +2778,7 @@
"path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha1-UTvb4tO5XXdi6METfvoZXGxhtbM="
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="
},
"path-is-absolute": {
"version": "1.0.1",
@@ -3686,7 +3686,7 @@
"wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha1-6Tk7oHEC5skaOyIUePAlfNKFblM=",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"requires": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
@@ -3696,7 +3696,7 @@
"ansi-regex": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha1-OIU59VF5vzkznIGvMKZU1p+Hy3U="
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg=="
},
"ansi-styles": {
"version": "4.3.0",
@@ -3709,7 +3709,7 @@
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
@@ -3717,12 +3717,12 @@
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI="
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
"integrity": "sha1-CxVx3XZpzNTz4G4U7x7tJiJa5TI=",
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
"requires": {
"ansi-regex": "^5.0.0"
}
@@ -3818,7 +3818,7 @@
"yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha1-vmjEl1xrKr9GkjawyHA2L6sJp7A=",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"

View File

@@ -16,27 +16,27 @@ describe('parseSpec method', function () {
let fileContent = fs.readFileSync(invalidSwaggerFolder + '/invalid_no_info_title.json', 'utf8');
const parsedSpec = concreteUtils.parseSpec(fileContent, {});
expect(parsedSpec.result).to.be.false;
expect(parsedSpec.reason).to.equal('The info property must have title and version defined');
expect(parsedSpec.reason).to.equal('Title, and version fields are required for the Info Object');
});
it('should return false and swagger must have info object message', function () {
let fileContent = fs.readFileSync(invalidSwaggerFolder + '/invalid_no_info.json', 'utf8');
const parsedSpec = concreteUtils.parseSpec(fileContent, {});
expect(parsedSpec.result).to.be.false;
expect(parsedSpec.reason).to.equal('The Swagger object must have an \"info\" property');
expect(parsedSpec.reason).to.equal('The Swagger specification must have an \"info\" field');
});
it('should return false and invalid version message', function () {
let fileContent = fs.readFileSync(invalidSwaggerFolder + '/invalid_wrong_swagger_version.json', 'utf8');
const parsedSpec = concreteUtils.parseSpec(fileContent, {});
expect(parsedSpec.result).to.be.false;
expect(parsedSpec.reason).to.equal('The Swagger object must have the \"swagger\" property set to 2.0');
expect(parsedSpec.reason).to.equal('The value of swagger field must be 2.0');
});
it('should return false and no paths message', function () {
let fileContent = fs.readFileSync(invalidSwaggerFolder + '/invalid_no_paths.json', 'utf8');
const parsedSpec = concreteUtils.parseSpec(fileContent, {});
expect(parsedSpec.result).to.be.false;
expect(parsedSpec.reason).to.equal('The Swagger object must have a "paths" property');
expect(parsedSpec.reason).to.equal('The Swagger specification must have a "paths" field');
});
});