UNPKG

ephelan-spectral-ruleset

Version:
37 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = (targetVal, opts, paths) => { if (!targetVal) { return [ { message: '"servers" should be defined', }, ]; } if (!Array.isArray(targetVal)) { return [ { message: '"servers" config should be an array, got object' } ]; } const rootPath = paths.target !== void 0 ? paths.target : paths.given; const results = []; const expectedUrls = opts.required; const missingUrls = []; for (const u of expectedUrls) { if (!targetVal.find(c => c.url === u)) { missingUrls.push(u); } } if (missingUrls.length) { return [ { message: `OpenAPI \`servers\` object is missing the following required URLs: ${missingUrls.join(', ')}`, path: [...rootPath, 0] } ]; } return results; }; //# sourceMappingURL=expectServersConfig.js.map