GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — server/openapi/test.js at master · gitLibs/server Expand file tree/ Copy pathtest.jsMore file actions 79 lines (69 loc) · 2.18 KB / Copy pathtest.jsFile metadata and controls79 lines (69 loc) · 2.18 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 /* * SPDX-License-Identifier: AGPL-3.0-only * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/> */ const path = require("path"); const lodash = require("lodash"); const $RefParser = require("@apidevtools/json-schema-ref-parser"); const validator = require("oas-validator"); const colors = require("colors/safe"); async function main() { const filePath = "v0.yaml"; console.log("try to bundle", filePath); const openapi = await $RefParser.bundle(path.join(__dirname, filePath)); try { console.log("try to lint", filePath); // JSON deep copy to remove anchor await validator.validate(JSON.parse(JSON.stringify(openapi)), { lint: true, lintSkip: ["info-contact", "contact-properties", "tag-description"], }); } catch (e) { if (!e.options.warnings.length) { throw e; } for (const { pointer, ruleName, rule: { description }, } of e.options.warnings) { const path = dataPathToJSONPath(pointer); console.error(ruleName, colors.red(`${description}:`), path); } throw new Error(`${e.options.warnings.length} errors, failed to validate ${filePath}`); } } main().catch((e) => { console.error(e); process.exit(1); }); function dataPathToJSONPath(s) { const ptr = s.replaceAll("/", ".").replaceAll("~1", "/"); return ( "$" + ptr .split(".") .slice(1) .map((x) => { if (Number.isInteger(parseFloat(x))) { return `[${x}]`; } if (["/", "'", '"', "-"].filter((c) => lodash.includes(x, c)).length !== 0) { return `[${JSON.stringify(x)}]`; } return `.` + x; }) .join("") ); } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |