This commit is contained in:
Mike Kistler 2021-09-06 19:51:49 -05:00
Родитель b05380f4b4
Коммит a4049e9f0b
10 изменённых файлов: 416 добавлений и 101 удалений

Просмотреть файл

@ -7,7 +7,7 @@ module.exports = (pathItem, _opts, paths) => {
if (pathItem === null || typeof pathItem !== 'object') {
return [];
}
const path = paths.target || paths.given;
const path = paths.path || [];
const errors = [];

Просмотреть файл

@ -167,7 +167,7 @@ function validateErrorResponse(errorResponse, responsePath) {
module.exports = function errorResponse(responses, _opts, paths) {
const errors = [];
const path = paths.target || paths.given || [];
const path = paths.path || [];
// Note: az-default-response rule will flag missing default response
if (responses.default) {

Просмотреть файл

@ -11,7 +11,7 @@ module.exports = (operation, _opts, paths) => {
if (operation === null || typeof operation !== 'object') {
return [];
}
const path = paths.target || paths.given || [];
const path = paths.path || [];
const errors = [];

Просмотреть файл

@ -8,7 +8,7 @@ module.exports = (operation, _opts, paths) => {
if (operation === null || typeof operation !== 'object') {
return [];
}
const path = paths.target || paths.given;
const path = paths.path || [];
// responses is required property of an operation in OpenAPI 2.0, so if
// isn't present this will be flagged elsewhere -- just return;

Просмотреть файл

@ -7,7 +7,7 @@ module.exports = (targetVal, _opts, paths) => {
return [];
}
const path = paths.target || paths.given;
const path = paths.path || [];
// These errors will be caught elsewhere, so silently ignore here
if (!targetVal.in || !targetVal.name) {

Просмотреть файл

@ -18,7 +18,7 @@ module.exports = (targetVal, _opts, paths) => {
if (targetVal === null || typeof targetVal !== 'object') {
return [];
}
const path = paths.target || paths.given || [];
const path = paths.path || [];
const pathParams = targetVal.parameters ? targetVal.parameters.map((p) => p.name) : [];

464
package-lock.json сгенерированный
Просмотреть файл

@ -8,8 +8,10 @@
"version": "0.0.1",
"license": "MIT",
"devDependencies": {
"@stoplight/spectral-core": "^1.4.0",
"ajv": "^8.0.1",
"@stoplight/spectral-core": "1.4.0",
"@stoplight/spectral-ruleset-migrator": "^1.4.2",
"@stoplight/spectral-rulesets": "^1.2.4",
"ajv": "^8.6.2",
"eslint": "^7.30.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.4",
@ -970,6 +972,22 @@
"@sinonjs/commons": "^1.7.0"
}
},
"node_modules/@stoplight/better-ajv-errors": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@stoplight/better-ajv-errors/-/better-ajv-errors-0.2.0.tgz",
"integrity": "sha512-3vBbXBDplfeOGS2rT4PyOwJ1K0A7/NqlVXI6sJ/XchQlrMXFMKtj4qExBLxr4M9ZiiESu48uhbdS3Nx8A0S+ZA==",
"dev": true,
"dependencies": {
"jsonpointer": "^4.0.1",
"leven": "^3.1.0"
},
"engines": {
"node": ">=10.8"
},
"peerDependencies": {
"ajv": ">=8"
}
},
"node_modules/@stoplight/json": {
"version": "3.15.0",
"resolved": "https://registry.npmjs.org/@stoplight/json/-/json-3.15.0.tgz",
@ -1049,9 +1067,9 @@
}
},
"node_modules/@stoplight/spectral-core": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-core/-/spectral-core-1.5.0.tgz",
"integrity": "sha512-3Ray1u0o0Ktm+3hG+kJ0j9epFeSebyxsMxpwu3kxxpoxQuLf/y8GFEPylQVmqxxWmTXCZZ88/vNeorS3tyQcTQ==",
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-core/-/spectral-core-1.4.0.tgz",
"integrity": "sha512-8f+ciIC4gsBLu3pbedz9nsk1ZJQvhj60iHo+893itpCfKovJ8+/IxVHpC6nJyhFuhJByiQsdpTEQjkjs5vaVdg==",
"dev": true,
"dependencies": {
"@stoplight/better-ajv-errors": "0.2.0",
@ -1068,33 +1086,16 @@
"blueimp-md5": "2.18.0",
"expression-eval": "4.0.0",
"json-schema": "0.3.0",
"jsonpath-plus": "6.0.1",
"jsonpath-plus": "5.0.7",
"lodash": "~4.17.21",
"lodash.topath": "^4.5.2",
"minimatch": "3.0.4",
"nimma": "0.1.1",
"nimma": "0.0.0",
"tslib": "~2.3.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@stoplight/spectral-core/node_modules/@stoplight/better-ajv-errors": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@stoplight/better-ajv-errors/-/better-ajv-errors-0.2.0.tgz",
"integrity": "sha512-3vBbXBDplfeOGS2rT4PyOwJ1K0A7/NqlVXI6sJ/XchQlrMXFMKtj4qExBLxr4M9ZiiESu48uhbdS3Nx8A0S+ZA==",
"dev": true,
"dependencies": {
"jsonpointer": "^4.0.1",
"leven": "^3.1.0"
},
"engines": {
"node": ">=10.8"
},
"peerDependencies": {
"ajv": ">=8"
}
},
"node_modules/@stoplight/spectral-core/node_modules/@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
@ -1117,29 +1118,69 @@
"jsep": "^0.3.0"
}
},
"node_modules/@stoplight/spectral-core/node_modules/jsonpath-plus": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-6.0.1.tgz",
"integrity": "sha512-EvGovdvau6FyLexFH2OeXfIITlgIbgZoAZe3usiySeaIDm5QS+A10DKNpaPBBqqRSZr2HN6HVNXxtwUAr2apEw==",
"dev": true,
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/@stoplight/spectral-core/node_modules/nimma": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/nimma/-/nimma-0.1.1.tgz",
"integrity": "sha512-mYdfYSmKa9FoKfza0KtPxaAD/WF0DhitMEkr+4nq9scNSlwiBrn/a3aR7wHVgXGI20lfxyNUUVPHKasXYXLuyg==",
"node_modules/@stoplight/spectral-formats": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-formats/-/spectral-formats-1.0.1.tgz",
"integrity": "sha512-l4cZ6imTqdCmNI8eexvWMoSSptx2lmdFRXSiX7P9ZDdKeRjQkJ49U5OttRr69IBaWdiHEP8Gw/cfnZDYOJKD5A==",
"dev": true,
"dependencies": {
"astring": "^1.7.5"
"@stoplight/json": "3.15.0",
"@stoplight/spectral-core": "^1.1.0",
"@stoplight/types": "12.3.0",
"@types/json-schema": "^7.0.7"
},
"engines": {
"node": ">=12.20"
"node": ">=12"
}
},
"node_modules/@stoplight/spectral-formats/node_modules/@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
"integrity": "sha512-hgzUR1z5BlYvIzUeFK5pjs5JXSvEutA9Pww31+dVicBlunsG1iXopDx/cvfBY7rHOrgtZDuvyeK4seqkwAZ6Cg==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.4",
"utility-types": "^3.10.0"
},
"optionalDependencies": {
"jsonpath-plus": "^6.0.1",
"lodash.topath": "^4.5.2"
"engines": {
"node": ">=8"
}
},
"node_modules/@stoplight/spectral-functions": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-functions/-/spectral-functions-1.2.0.tgz",
"integrity": "sha512-hnsNlZjl33l0m9FW2U3H2PhCZHGOKKYh/iU56WCCdeEGazWHVRtRUnnvOPJHWDTiDHN8jYyJ7qTYl225pUAJtw==",
"dev": true,
"dependencies": {
"@stoplight/better-ajv-errors": "0.2.0",
"@stoplight/json": "3.15.0",
"@stoplight/spectral-core": "^1.1.0",
"@stoplight/spectral-formats": "^1.0.0",
"@stoplight/spectral-runtime": "*",
"@stoplight/types": "12.3.0",
"ajv": "~8.6.0",
"ajv-errors": "~3.0.0",
"ajv-formats": "~2.1.0",
"json-schema-migrate": "~2.0.0",
"json-schema-traverse": "~1.0.0",
"lodash": "~4.17.21",
"tslib": "^2.3.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@stoplight/spectral-functions/node_modules/@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
"integrity": "sha512-hgzUR1z5BlYvIzUeFK5pjs5JXSvEutA9Pww31+dVicBlunsG1iXopDx/cvfBY7rHOrgtZDuvyeK4seqkwAZ6Cg==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.4",
"utility-types": "^3.10.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@stoplight/spectral-parsers": {
@ -1224,6 +1265,78 @@
"node": ">= 0.6.0"
}
},
"node_modules/@stoplight/spectral-ruleset-migrator": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-ruleset-migrator/-/spectral-ruleset-migrator-1.4.2.tgz",
"integrity": "sha512-egW1wbYVBUdtozHiqDYtDXrSBmU4ep3/kLQ46Il7KmDxzQFDTcn7UfXiiUjEhBlrc56fZymSE3HEQdaUKYqypA==",
"dev": true,
"dependencies": {
"@stoplight/json": "3.15.0",
"@stoplight/ordered-object-literal": "^1.0.2",
"@stoplight/path": "1.3.2",
"@stoplight/spectral-functions": "^1.0.0",
"@stoplight/spectral-runtime": "*",
"@stoplight/types": "12.3.0",
"@stoplight/yaml": "4.2.2",
"@types/node": "*",
"ajv": "^8.6.0",
"ast-types": "0.14.2",
"astring": "^1.7.5",
"reserved": "0.1.2"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@stoplight/spectral-ruleset-migrator/node_modules/@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
"integrity": "sha512-hgzUR1z5BlYvIzUeFK5pjs5JXSvEutA9Pww31+dVicBlunsG1iXopDx/cvfBY7rHOrgtZDuvyeK4seqkwAZ6Cg==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.4",
"utility-types": "^3.10.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@stoplight/spectral-rulesets": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-rulesets/-/spectral-rulesets-1.2.4.tgz",
"integrity": "sha512-m5zODWb2g+I26GmLnClvMOBP0KSC+uVr4AiUzSrd/ianMcd+cSxtUu4cDl+syJQjr8fwjnzibuxQWh+WLjuVcw==",
"dev": true,
"dependencies": {
"@stoplight/better-ajv-errors": "0.2.0",
"@stoplight/json": "3.15.0",
"@stoplight/spectral-core": "^1.3.0",
"@stoplight/spectral-formats": "^1.0.1",
"@stoplight/spectral-functions": "^1.1.2",
"@stoplight/types": "^12.3.0",
"@types/json-schema": "^7.0.7",
"ajv": "~8.6.0",
"ajv-formats": "~2.1.0",
"json-schema-traverse": "^1.0.0",
"lodash": "~4.17.21",
"tslib": "^2.3.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@stoplight/spectral-rulesets/node_modules/@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
"integrity": "sha512-hgzUR1z5BlYvIzUeFK5pjs5JXSvEutA9Pww31+dVicBlunsG1iXopDx/cvfBY7rHOrgtZDuvyeK4seqkwAZ6Cg==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.4",
"utility-types": "^3.10.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@stoplight/spectral-runtime": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-runtime/-/spectral-runtime-1.1.0.tgz",
@ -1668,6 +1781,18 @@
"node": ">= 0.4"
}
},
"node_modules/ast-types": {
"version": "0.14.2",
"resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.14.2.tgz",
"integrity": "sha512-O0yuUDnZeQDL+ncNGlJ78BiO4jnYI3bvMsD5prT0/nsgijG/LpNBIr63gTjVTNsiGkgQhiyCShTgxt8oXOrklA==",
"dev": true,
"dependencies": {
"tslib": "^2.0.1"
},
"engines": {
"node": ">=4"
}
},
"node_modules/astral-regex": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
@ -4568,6 +4693,15 @@
"integrity": "sha512-TYfxx36xfl52Rf1LU9HyWSLGPdYLL+SQ8/E/0yVyKG8wCCDaSrhPap0vEdlsZWRaS6tnKKLPGiEJGiREVC8kxQ==",
"dev": true
},
"node_modules/json-schema-migrate": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/json-schema-migrate/-/json-schema-migrate-2.0.0.tgz",
"integrity": "sha512-r38SVTtojDRp4eD6WsCqiE0eNDt4v1WalBXb9cyZYw9ai5cGtBwzRNWjHzJl38w6TxFkXAIA7h+fyX3tnrAFhQ==",
"dev": true,
"dependencies": {
"ajv": "^8.0.0"
}
},
"node_modules/json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
@ -4598,6 +4732,15 @@
"integrity": "sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w==",
"dev": true
},
"node_modules/jsonpath-plus": {
"version": "5.0.7",
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-5.0.7.tgz",
"integrity": "sha512-7TS6wsiw1s2UMK/A6nA4n0aUJuirCVhJ87nWX5je5MPOl0z5VTr2qs7nMP8NZ2ed3rlt6kePTqddgVPE9F0i0w==",
"dev": true,
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/jsonpointer": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.1.0.tgz",
@ -4771,12 +4914,6 @@
"lodash._reinterpolate": "^3.0.0"
}
},
"node_modules/lodash.topath": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.topath/-/lodash.topath-4.5.2.tgz",
"integrity": "sha1-NhY1Hzu6YZlKCTGYlmC9AyVP0Ak=",
"dev": true
},
"node_modules/lodash.truncate": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz",
@ -4958,6 +5095,19 @@
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"dev": true
},
"node_modules/nimma": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/nimma/-/nimma-0.0.0.tgz",
"integrity": "sha512-if0VqyHpTMHKFORMiJ2WLWgoIF4xqwjybHZyvodQ/yCmiWag6RhLlMHeFukz4X31DanTBA26U+HwvXIrTaYQkQ==",
"dev": true,
"dependencies": {
"astring": "^1.4.3",
"jsep": "^0.3.4"
},
"engines": {
"node": ">=10"
}
},
"node_modules/node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
@ -5728,6 +5878,15 @@
"node": ">=0.10.0"
}
},
"node_modules/reserved": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/reserved/-/reserved-0.1.2.tgz",
"integrity": "sha1-cHsSRqMmn3Vdp8/Pmvb0mDvvEFw=",
"dev": true,
"engines": {
"node": ">=0.8"
}
},
"node_modules/resolve": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
@ -7401,6 +7560,16 @@
"@sinonjs/commons": "^1.7.0"
}
},
"@stoplight/better-ajv-errors": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@stoplight/better-ajv-errors/-/better-ajv-errors-0.2.0.tgz",
"integrity": "sha512-3vBbXBDplfeOGS2rT4PyOwJ1K0A7/NqlVXI6sJ/XchQlrMXFMKtj4qExBLxr4M9ZiiESu48uhbdS3Nx8A0S+ZA==",
"dev": true,
"requires": {
"jsonpointer": "^4.0.1",
"leven": "^3.1.0"
}
},
"@stoplight/json": {
"version": "3.15.0",
"resolved": "https://registry.npmjs.org/@stoplight/json/-/json-3.15.0.tgz",
@ -7466,9 +7635,9 @@
"dev": true
},
"@stoplight/spectral-core": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-core/-/spectral-core-1.5.0.tgz",
"integrity": "sha512-3Ray1u0o0Ktm+3hG+kJ0j9epFeSebyxsMxpwu3kxxpoxQuLf/y8GFEPylQVmqxxWmTXCZZ88/vNeorS3tyQcTQ==",
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-core/-/spectral-core-1.4.0.tgz",
"integrity": "sha512-8f+ciIC4gsBLu3pbedz9nsk1ZJQvhj60iHo+893itpCfKovJ8+/IxVHpC6nJyhFuhJByiQsdpTEQjkjs5vaVdg==",
"dev": true,
"requires": {
"@stoplight/better-ajv-errors": "0.2.0",
@ -7485,24 +7654,13 @@
"blueimp-md5": "2.18.0",
"expression-eval": "4.0.0",
"json-schema": "0.3.0",
"jsonpath-plus": "6.0.1",
"jsonpath-plus": "5.0.7",
"lodash": "~4.17.21",
"lodash.topath": "^4.5.2",
"minimatch": "3.0.4",
"nimma": "0.1.1",
"nimma": "0.0.0",
"tslib": "~2.3.0"
},
"dependencies": {
"@stoplight/better-ajv-errors": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@stoplight/better-ajv-errors/-/better-ajv-errors-0.2.0.tgz",
"integrity": "sha512-3vBbXBDplfeOGS2rT4PyOwJ1K0A7/NqlVXI6sJ/XchQlrMXFMKtj4qExBLxr4M9ZiiESu48uhbdS3Nx8A0S+ZA==",
"dev": true,
"requires": {
"jsonpointer": "^4.0.1",
"leven": "^3.1.0"
}
},
"@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
@ -7521,22 +7679,62 @@
"requires": {
"jsep": "^0.3.0"
}
},
"jsonpath-plus": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-6.0.1.tgz",
"integrity": "sha512-EvGovdvau6FyLexFH2OeXfIITlgIbgZoAZe3usiySeaIDm5QS+A10DKNpaPBBqqRSZr2HN6HVNXxtwUAr2apEw==",
"dev": true
},
"nimma": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/nimma/-/nimma-0.1.1.tgz",
"integrity": "sha512-mYdfYSmKa9FoKfza0KtPxaAD/WF0DhitMEkr+4nq9scNSlwiBrn/a3aR7wHVgXGI20lfxyNUUVPHKasXYXLuyg==",
}
}
},
"@stoplight/spectral-formats": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-formats/-/spectral-formats-1.0.1.tgz",
"integrity": "sha512-l4cZ6imTqdCmNI8eexvWMoSSptx2lmdFRXSiX7P9ZDdKeRjQkJ49U5OttRr69IBaWdiHEP8Gw/cfnZDYOJKD5A==",
"dev": true,
"requires": {
"@stoplight/json": "3.15.0",
"@stoplight/spectral-core": "^1.1.0",
"@stoplight/types": "12.3.0",
"@types/json-schema": "^7.0.7"
},
"dependencies": {
"@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
"integrity": "sha512-hgzUR1z5BlYvIzUeFK5pjs5JXSvEutA9Pww31+dVicBlunsG1iXopDx/cvfBY7rHOrgtZDuvyeK4seqkwAZ6Cg==",
"dev": true,
"requires": {
"astring": "^1.7.5",
"jsonpath-plus": "^6.0.1",
"lodash.topath": "^4.5.2"
"@types/json-schema": "^7.0.4",
"utility-types": "^3.10.0"
}
}
}
},
"@stoplight/spectral-functions": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-functions/-/spectral-functions-1.2.0.tgz",
"integrity": "sha512-hnsNlZjl33l0m9FW2U3H2PhCZHGOKKYh/iU56WCCdeEGazWHVRtRUnnvOPJHWDTiDHN8jYyJ7qTYl225pUAJtw==",
"dev": true,
"requires": {
"@stoplight/better-ajv-errors": "0.2.0",
"@stoplight/json": "3.15.0",
"@stoplight/spectral-core": "^1.1.0",
"@stoplight/spectral-formats": "^1.0.0",
"@stoplight/spectral-runtime": "*",
"@stoplight/types": "12.3.0",
"ajv": "~8.6.0",
"ajv-errors": "~3.0.0",
"ajv-formats": "~2.1.0",
"json-schema-migrate": "~2.0.0",
"json-schema-traverse": "~1.0.0",
"lodash": "~4.17.21",
"tslib": "^2.3.0"
},
"dependencies": {
"@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
"integrity": "sha512-hgzUR1z5BlYvIzUeFK5pjs5JXSvEutA9Pww31+dVicBlunsG1iXopDx/cvfBY7rHOrgtZDuvyeK4seqkwAZ6Cg==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.4",
"utility-types": "^3.10.0"
}
}
}
@ -7611,6 +7809,70 @@
}
}
},
"@stoplight/spectral-ruleset-migrator": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-ruleset-migrator/-/spectral-ruleset-migrator-1.4.2.tgz",
"integrity": "sha512-egW1wbYVBUdtozHiqDYtDXrSBmU4ep3/kLQ46Il7KmDxzQFDTcn7UfXiiUjEhBlrc56fZymSE3HEQdaUKYqypA==",
"dev": true,
"requires": {
"@stoplight/json": "3.15.0",
"@stoplight/ordered-object-literal": "^1.0.2",
"@stoplight/path": "1.3.2",
"@stoplight/spectral-functions": "^1.0.0",
"@stoplight/spectral-runtime": "*",
"@stoplight/types": "12.3.0",
"@stoplight/yaml": "4.2.2",
"@types/node": "*",
"ajv": "^8.6.0",
"ast-types": "0.14.2",
"astring": "^1.7.5",
"reserved": "0.1.2"
},
"dependencies": {
"@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
"integrity": "sha512-hgzUR1z5BlYvIzUeFK5pjs5JXSvEutA9Pww31+dVicBlunsG1iXopDx/cvfBY7rHOrgtZDuvyeK4seqkwAZ6Cg==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.4",
"utility-types": "^3.10.0"
}
}
}
},
"@stoplight/spectral-rulesets": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-rulesets/-/spectral-rulesets-1.2.4.tgz",
"integrity": "sha512-m5zODWb2g+I26GmLnClvMOBP0KSC+uVr4AiUzSrd/ianMcd+cSxtUu4cDl+syJQjr8fwjnzibuxQWh+WLjuVcw==",
"dev": true,
"requires": {
"@stoplight/better-ajv-errors": "0.2.0",
"@stoplight/json": "3.15.0",
"@stoplight/spectral-core": "^1.3.0",
"@stoplight/spectral-formats": "^1.0.1",
"@stoplight/spectral-functions": "^1.1.2",
"@stoplight/types": "^12.3.0",
"@types/json-schema": "^7.0.7",
"ajv": "~8.6.0",
"ajv-formats": "~2.1.0",
"json-schema-traverse": "^1.0.0",
"lodash": "~4.17.21",
"tslib": "^2.3.0"
},
"dependencies": {
"@stoplight/types": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz",
"integrity": "sha512-hgzUR1z5BlYvIzUeFK5pjs5JXSvEutA9Pww31+dVicBlunsG1iXopDx/cvfBY7rHOrgtZDuvyeK4seqkwAZ6Cg==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.4",
"utility-types": "^3.10.0"
}
}
}
},
"@stoplight/spectral-runtime": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-runtime/-/spectral-runtime-1.1.0.tgz",
@ -7984,6 +8246,15 @@
"es-abstract": "^1.18.0-next.1"
}
},
"ast-types": {
"version": "0.14.2",
"resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.14.2.tgz",
"integrity": "sha512-O0yuUDnZeQDL+ncNGlJ78BiO4jnYI3bvMsD5prT0/nsgijG/LpNBIr63gTjVTNsiGkgQhiyCShTgxt8oXOrklA==",
"dev": true,
"requires": {
"tslib": "^2.0.1"
}
},
"astral-regex": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
@ -10359,6 +10630,15 @@
"integrity": "sha512-TYfxx36xfl52Rf1LU9HyWSLGPdYLL+SQ8/E/0yVyKG8wCCDaSrhPap0vEdlsZWRaS6tnKKLPGiEJGiREVC8kxQ==",
"dev": true
},
"json-schema-migrate": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/json-schema-migrate/-/json-schema-migrate-2.0.0.tgz",
"integrity": "sha512-r38SVTtojDRp4eD6WsCqiE0eNDt4v1WalBXb9cyZYw9ai5cGtBwzRNWjHzJl38w6TxFkXAIA7h+fyX3tnrAFhQ==",
"dev": true,
"requires": {
"ajv": "^8.0.0"
}
},
"json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
@ -10386,6 +10666,12 @@
"integrity": "sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w==",
"dev": true
},
"jsonpath-plus": {
"version": "5.0.7",
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-5.0.7.tgz",
"integrity": "sha512-7TS6wsiw1s2UMK/A6nA4n0aUJuirCVhJ87nWX5je5MPOl0z5VTr2qs7nMP8NZ2ed3rlt6kePTqddgVPE9F0i0w==",
"dev": true
},
"jsonpointer": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.1.0.tgz",
@ -10531,12 +10817,6 @@
"lodash._reinterpolate": "^3.0.0"
}
},
"lodash.topath": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.topath/-/lodash.topath-4.5.2.tgz",
"integrity": "sha1-NhY1Hzu6YZlKCTGYlmC9AyVP0Ak=",
"dev": true
},
"lodash.truncate": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz",
@ -10686,6 +10966,16 @@
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"dev": true
},
"nimma": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/nimma/-/nimma-0.0.0.tgz",
"integrity": "sha512-if0VqyHpTMHKFORMiJ2WLWgoIF4xqwjybHZyvodQ/yCmiWag6RhLlMHeFukz4X31DanTBA26U+HwvXIrTaYQkQ==",
"dev": true,
"requires": {
"astring": "^1.4.3",
"jsep": "^0.3.4"
}
},
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
@ -11278,6 +11568,12 @@
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
"dev": true
},
"reserved": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/reserved/-/reserved-0.1.2.tgz",
"integrity": "sha1-cHsSRqMmn3Vdp8/Pmvb0mDvvEFw=",
"dev": true
},
"resolve": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",

Просмотреть файл

@ -15,8 +15,10 @@
"url": "https://github.com/Azure/azure-spectral-ruleset"
},
"devDependencies": {
"@stoplight/spectral-core": "^1.4.0",
"ajv": "^8.0.1",
"@stoplight/spectral-core": "1.4.0",
"@stoplight/spectral-ruleset-migrator": "^1.4.2",
"@stoplight/spectral-rulesets": "^1.2.4",
"ajv": "^8.6.2",
"eslint": "^7.30.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.4",

Просмотреть файл

@ -18,7 +18,7 @@ test('az-path-characters should find errors', () => {
};
return linter.run(oasDoc).then((results) => {
expect(results.length).toBe(3);
expect(results[0].path.join('.')).toBe('paths' /* ./api[]' */);
expect(results[0].path.join('.')).toBe('paths./api[]');
expect(results[1].path.join('.')).toBe('paths./foo:bar/{baz}');
expect(results[2].path.join('.')).toBe('paths./foo/{bar}:baz/qux');
});

Просмотреть файл

@ -1,16 +1,33 @@
const { Spectral, isOpenApiv2, isOpenApiv3 } = require('@stoplight/spectral');
const { Spectral } = require('@stoplight/spectral-core');
const { migrateRuleset } = require('@stoplight/spectral-ruleset-migrator');
const fs = require('fs');
const path = require('path');
const rulesetURI = `${__dirname}/../spectral.yaml`;
const AsyncFunction = (async () => {}).constructor;
const rulesetFile = './spectral.yaml';
async function linterForRule(rule) {
const linter = new Spectral();
linter.registerFormat('oas2', isOpenApiv2);
linter.registerFormat('oas3', isOpenApiv3);
await linter.loadRuleset(rulesetURI);
Object.keys(linter.rules).forEach((key) => {
// eslint-disable-next-line no-param-reassign
linter.rules[key].enabled = (key === rule);
const m = {};
const paths = [path.dirname(rulesetFile), __dirname, '..'];
await AsyncFunction(
'module, require',
await migrateRuleset(rulesetFile, {
format: 'commonjs',
fs,
}),
// eslint-disable-next-line import/no-dynamic-require,global-require
)(m, (text) => require(require.resolve(text, { paths })));
const ruleset = m.exports;
delete ruleset.extends;
Object.keys(ruleset.rules).forEach((key) => {
if (key !== rule) {
delete ruleset.rules[key];
}
});
linter.setRuleset(ruleset);
return linter;
}