UNPKG

ephelan-spectral-ruleset

Version:
44 lines 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const expectedBearerObj = { scheme: 'bearer', bearerFormat: 'JWT', type: 'http' }; exports.default = (targetVal, _, paths) => { if (!targetVal) { return [ { message: 'OpenAPI object `components` should contain a `securitySchemes` object.', path: [...paths.target] } ]; } if (!targetVal.Bearer) { return [ { message: 'OpenAPI object `components.securitySchemes` should contain a `Bearer` object' } ]; } const bearerObject = targetVal.Bearer; const results = []; const rootPath = paths.target !== void 0 ? paths.target : paths.given; const path = [...rootPath, 'Bearer', 'securitySchemes']; for (const [key, val] of Object.entries(expectedBearerObj)) { if (!bearerObject[key]) { results.push({ message: `Missing expected key "${key}" in Bearer object`, path: [...path, key] }); } if (bearerObject[key] != val) { results.push({ message: `"${key}" should be "${expectedBearerObj[key]}"`, path: [...path, key] }); } } return results; }; //# sourceMappingURL=securitySchemes.js.map